-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
This is the continuation of #3814.
See the discussion there for the long form.
Short form, the following script should produce the given result. Two fail as shown by specs in #3814, and one works currently but may be the incorrect fix (#2458).
class Enumerator::Yielder
def yield(*args)
@proc.call(*args)
end
end
module Enumerable
def first
val = nil
catch(:foo) do
each do |x|
val = x
throw :foo
end
end
val
end
end
p Enumerator.new {|y| y.yield([1])}.to_a
p Enumerator.new {|y| y << [1]}.to_a
p Enumerator.new {|y| y.yield([1])}.map {|e| e}.to_a
p Enumerator.new {|y| y.yield([1])}.lazy.map {|e| e}.to_a
p Enumerator.new {|y| y.yield [1]}.first$ jruby blah.rb
[[1]]
[[1]]
[[1]]
[[1]]
[1]
Reactions are currently unavailable