Permalink
Browse files

Patched Kernel#loop for 1.9

  • Loading branch information...
1 parent 5e88b23 commit a22811b2ced8eff92a4d74ce10c48ff496434356 @jtdowney jtdowney committed Oct 22, 2011
Showing with 24 additions and 13 deletions.
  1. +0 −12 kernel/common/kernel.rb
  2. +12 −0 kernel/common/kernel18.rb
  3. +12 −0 kernel/common/kernel19.rb
  4. +0 −1 spec/tags/19/ruby/core/kernel/loop_tags.txt
View
@@ -224,18 +224,6 @@ def global_variables
end
module_function :global_variables
- def loop
- raise LocalJumpError, "no block given" unless block_given?
-
- begin
- while true
- yield
- end
- rescue StopIteration
- end
- end
- module_function :loop
-
#
# Sleeps the current thread for +duration+ seconds.
#
View
@@ -9,6 +9,18 @@ def to_a
end
end
+ def loop
+ raise LocalJumpError, "no block given" unless block_given?
+
+ begin
+ while true
+ yield
+ end
+ rescue StopIteration
+ end
+ end
+ module_function :loop
+
def Integer(obj)
case obj
when Integer
View
@@ -7,6 +7,18 @@ class << self
end.send(:define_method, *args, &block)
end
+ def loop
+ return to_enum(:loop) unless block_given?
+
+ begin
+ while true
+ yield
+ end
+ rescue StopIteration
+ end
+ end
+ module_function :loop
+
def Integer(obj, base=nil)
if obj.kind_of? String
if obj.empty?
@@ -1 +0,0 @@
-fails:Kernel.loop returns an enumerator if no block given

0 comments on commit a22811b

Please sign in to comment.