Loops/Downward for: Difference between revisions

Line 1,815:
Thus the first variant is one message send (aka virtual function call) to the number, whereas the second is two message sends and an object instantiation.
 
The nice thing with Intervals is that they can be concatenated with a <tt>","</tt> operator (like all collections); thus, I could alsalso write:
<lang smalltalk>(10 to: 6 by: -1),(1 to: 5) do:[:aNumber |
aNumber displayNl.
]</lang>
to enumerate in a different order,
<br>or combine ranges with a constant array:
<lang smalltalk>(10 to: 2 by: -2),#(99 999),(1 to: 10 by: 2) do:[:aNumber |
aNumber displayNl.
Anonymous user