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 have an array of ojbects which are baisically acting like structures. > I want to pass the array to a function. This function will take the > array, make a new copy so as to protect the original from any changes. > Changes will be made to the copy and then the copy is returned. > > How do i do that? > > Ive looked dup but i dont think it works for objects... isnt there a > method to copy an object (i.e make new space in memory and put the data > there rather than juts pointing to the original objects address). > > Id have thought it was necessary if you can only pass by reference...or > is the above considered bad design practice in ruby? Have a look at this post: http://al2o3-cr.blogspot.com/2008/08/object-arr.html it explains your case a bit. -- Posted via http://www.ruby-forum.com/.