Next: Invoking code blocks, Previous: Integer loops, Up: Code blocks (II)
It is also possible to represent a range of numbers as a standalone object. This allows you to represent a range of numbers as a single object, which can be passed around the system.
i := Interval from: 5 to: 10 i do: [:x | x printNl]
As with the integer loops, the Interval class can also represent steps greater than 1. It is done much like it was for our numeric loop above:
i := (Interval from: 5 to: 10 by: 2) i do: [:x| x printNl]