Learn Ruby

Saturday, April 14, 2007

 

Array.new

if use Array.new(size, TargetClass.new(...))
Then all the element of this array POINT to the same object
Then modified one entry will result the modification to others
My solution is

a = Array.new(size)
for i in 0...size
a[i].new(...)
end


can it be improved?

Labels:


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

Archives

July 2006   April 2007  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]