rng.step(n=1) {| obj | block } â rng
rng.step(n=1) â an_enumerator
rng.step(n=1) â an_enumerator
Instance Public methods
Iterates over the range, passing each n
th element to the
block. If begin and end are numeric, n
is added for each
iteration. Otherwise step
invokes succ
to iterate
through range elements.
If no block is given, an enumerator is returned instead.
1 2 3 4 | range = Xs. new ( 1 )..Xs. new ( 10 ) range.step( 2 ) {|x| puts x} puts range.step( 3 ) {|x| puts x} |
produces:
1 2 3 4 5 6 7 8 9 10 | 1 x 3 xxx 5 xxxxx 7 xxxxxxx 9 xxxxxxxxx 1 x 4 xxxx 7 xxxxxxx 10 xxxxxxxxxx |
See Range for the definition of class Xs.
Please login to continue.