Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Patched Kernel#loop for 1.9

  • Loading branch information...
commit a22811b2ced8eff92a4d74ce10c48ff496434356 1 parent 5e88b23
@jtdowney jtdowney authored
View
12 kernel/common/kernel.rb
@@ -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
12 kernel/common/kernel18.rb
@@ -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
12 kernel/common/kernel19.rb
@@ -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?
View
1  spec/tags/19/ruby/core/kernel/loop_tags.txt
@@ -1 +0,0 @@
-fails:Kernel.loop returns an enumerator if no block given
Please sign in to comment.
Something went wrong with that request. Please try again.