Commit bbab89e7 authored by TOMITA Masahiro's avatar TOMITA Masahiro

Fix: Numeric#step infinite loop.

parent 1365151d
......@@ -101,12 +101,20 @@ 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
while(i <= num)
block.call(i)
i += step
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
......
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