Commit dd149736 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2655 from tmtm/fix-numeric-step

Fix: Numeric#step infinite loop.
parents 1365151d bbab89e7
......@@ -101,13 +101,21 @@ module Integral
# incremented by +step+ (default 1).
#
def step(num, step=1, &block)
raise ArgumentError, "step can't be 0" if step == 0
return to_enum(:step, num, step) unless block_given?
i = if num.kind_of? Float then self.to_f else self end
if step > 0
while(i <= num)
block.call(i)
i += step
end
else
while(i >= num)
block.call(i)
i += step
end
end
self
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment