Skip to content

early return in each'd enumerator is jumping out of each and not method #2736

Closed
@enebo

Description

@enebo

I stumbled across this not working on JRuby directly (I usually never hit real bugs in JRuby unless I am working on what someone else reports EXCITING!)...for the humanity...We should not be printing out OH UH. The return is a lexical return and should return from foo:

e = Enumerator.new do |yielder|
  [1,2,3].each { |i| yielder << i }
end


def foo(e)
  e.each do |i|
    p i
    return if i == 2
    p i
  end
  p "OH UH"
end

foo e

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions