Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Patched Kernel#loop for 1.9 #1334

Merged
merged 1 commit into from

2 participants

@jtdowney

Moved the implementation to separate files and changed the 1.9 behavior to return an enumerator.

@davorb davorb merged commit 231f00e into rubinius:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 22, 2011
  1. @jtdowney

    Patched Kernel#loop for 1.9

    jtdowney authored
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.