Commit ef17231b authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

Integer#step added

parent 4de0a2af
##
# Integer
#
#
# ISO 15.2.8
class Integer
......@@ -44,6 +44,19 @@ class Integer
end
self
end
##
# Calls the given block from +self+ to +num+
# incremented by +step+ (default 1).
#
def step(num, step=1, &block)
i = if num.kind_of? Float then self.to_f else self end
while(i <= num)
block.call(i)
i += step
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