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: 80@25. map doXY: [:xy| map atXY:xy put:#stone].
Or even:
grid := Grid new: 80@25 fill: #stone.
Marcus has his 2DArray but it's peppered with caveats.
Thoughts?
===Blake===