Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1334 from jtdowney/kernel-loop-patch

Patched Kernel#loop for 1.9
  • Loading branch information...
commit 231f00ef731b8bff20a75400ac976422e3731691 2 parents 5e88b23 + a22811b
@davorb davorb 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.