summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
Diffstat (limited to 'mrblib')
-rw-r--r--mrblib/numeric.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/mrblib/numeric.rb b/mrblib/numeric.rb
index 034019e8b..5be3c90fc 100644
--- a/mrblib/numeric.rb
+++ b/mrblib/numeric.rb
@@ -45,6 +45,8 @@ module Integral
#
# ISO 15.2.8.3.15
def downto(num, &block)
+ return to_enum(:downto, num) unless block_given?
+
i = self.to_i
while(i >= num)
block.call(i)
@@ -84,6 +86,8 @@ module Integral
#
# ISO 15.2.8.3.27
def upto(num, &block)
+ return to_enum(:upto, num) unless block_given?
+
i = self.to_i
while(i <= num)
block.call(i)
@@ -97,6 +101,8 @@ module Integral
# incremented by +step+ (default 1).
#
def step(num, step=1, &block)
+ 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)