Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
enebo opened this issue Mar 20, 2015 · 1 comment
Closed

Comments

@enebo
Copy link
Member

enebo commented Mar 20, 2015

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
@enebo enebo added this to the 9.0.0.0.pre2 milestone Mar 20, 2015
@enebo
Copy link
Member Author

enebo commented Mar 20, 2015

I should add if we replace 'e' with an array or standard core data structure this works as expected...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant