Actions
Bug #15537
closedNumeric#step doesn't iterate under some conditions
Description
Numeric#step doesn't iterate under the following conditions:
- receiver and/or
by
areFloat
-
by
is negative -
to
is default - without block
Example:¶
Good:
p 1.step(by: 3).take(2) #=> [1, 4]
p 1.step(by: -3).take(2) #=> [1, -2]
p 1.step(by: 3.0).take(2) #=> [1.0, 4.0]
p 1.0.step(by: 3).take(2) #=> [1.0, 4.0]
a=[]; p 1.step(by: -3.0){|n|break a if (a << n).size == 2} #=> [1.0, -2.0]
a=[]; p 1.0.step(by: -3){|n|break a if (a << n).size == 2} #=> [1.0, -2.0]
Bad:
p 1.step(by: -3.0).take(2) #=> []
p 1.0.step(by: -3).take(2) #=> []
I have attached a patch.
Files
Actions
Like0
Like0Like0