In a Sequencable collection, doWithIndex seems to just call withIndexDo.
Is there a "do" that passes just the index, not the object?
My son is working on a roguelike, and we're looking at various ways of
creating the map. This is a two-dimensional map that would fit in a
character-mode, and we have this so far:
| map xBound yBound |
xBound := 80.
yBound := 24.
map := Array new: xBound.
i := 1.
[i <= xBound] whileTrue: [
map at:i put: (Array new:yBound).
i := i + 1
].
map do: [ :col|
col withIndexDo: [:obj :y|
col at:y put:#stone.
]
].
This seems to lack elegance. Better would be:
map := 2DArray new: [EMAIL PROTECTED]
map doXY: [:xy| map atXY:xy put:#stone].
Or even:
grid := Grid new: [EMAIL PROTECTED] fill: #stone.
Marcus has his 2DArray but it's peppered with caveats.
Thoughts?
===Blake===
_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners