[Newbies] Arrays within arrays
Charles Gray
tcykgreis at gmail.com
Thu Sep 4 15:14:44 UTC 2008
Why doesn't this work?
strength := Array new: 10.
strength := #( #(0 0 0 0) #(0 0 0 0) #(0 0 0 0) #(0 0 0 0) #(0 0 0 0) #(0 0 0 0)
#(2 1 0 0) #( 8 4 0 1) #(14 6 0 2) #(30 12 1 4)).
I read that the contents of an array are objects and the arrays inside of
strength are objects but Smalltalk simply refuses to accept this assignment. I
didn't want to say a := #(0 0 0 0). b := #(2 1 0 0). c := #(8 4 0 1) ... etc.
and then strength := #( a a a a a a b c ... etc but it appears this may be
necessary. I suppose a, b, c, etc are temporary variables and will disappear
after use but it seems like a terrible waste.
More information about the Beginners
mailing list