From: "David A. Black" Date: 2008-08-28T02:09:42+09:00 Subject: Re: how to avoid passing by reference and how to copy objects Hi -- On Wed, 27 Aug 2008, Adam Akhtar wrote: > Hi after a bit of searching and reading im quite confused by this. > > I first learnt C so used to being able to pass by reference or by value. > In Ruby its just by reference (so ive just found out after an hour of > chasing a bug). I know this sounds pedantic, but I think it's really pass by value, with the values being references. In other words, if you do this: a = [1,2,3] you're binding the identifier a to a reference to the array. If you then do: puts a you're passing the value of a (which is a reference to an array) to puts. In practical terms it doesn't matter, but it helps make sense of, for example, the fact that you can't pass a reference-by-reference. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL See http://www.rubypal.com for details and updates!