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

Ignore nil for ifnone argument in Enumerable#find #5726

Merged
merged 1 commit into from May 6, 2019

Conversation

@davishmcclurg
Copy link
Contributor

commented May 5, 2019

MRI allows calling find(nil) and treats it as if no ifnone proc was
passed:

$ RBENV_VERSION=2.5.3 ruby -e 'puts [1,2,3].find(nil) { false }.inspect'
nil
$ RBENV_VERSION=jruby-9.2.7.0 ruby -e 'puts [1,2,3].find(nil) { false }.inspect'
NoMethodError: undefined method `call' for nil:NilClass
Did you mean?  caller
    find at org/jruby/RubyEnumerable.java:656
  <main> at -e:1
Ignore nil for ifnone argument in Enumerable#find
MRI allows calling `find(nil)` and treats it as if no ifnone proc was
passed:

```
$ RBENV_VERSION=2.5.3 ruby -e 'puts [1,2,3].find(nil) { false }.inspect'
nil
$ RBENV_VERSION=jruby-9.2.7.0 ruby -e 'puts [1,2,3].find(nil) { false }.inspect'
NoMethodError: undefined method `call' for nil:NilClass
Did you mean?  caller
    find at org/jruby/RubyEnumerable.java:656
  <main> at -e:1
```

@kares kares merged commit 961f4a6 into jruby:master May 6, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
jruby.jruby Build #20190505.1 succeeded
Details

@kares kares added this to the JRuby 9.2.8.0 milestone May 6, 2019

eregon added a commit to ruby/spec that referenced this pull request May 28, 2019

[fix] Ignore nil for ifnone argument in Enumerable#find (jruby/jruby#…
…5726)

MRI allows calling `find(nil)` and treats it as if no ifnone proc was
passed:

```
$ RBENV_VERSION=2.5.3 ruby -e 'puts [1,2,3].find(nil) { false }.inspect'
nil
$ RBENV_VERSION=jruby-9.2.7.0 ruby -e 'puts [1,2,3].find(nil) { false }.inspect'
NoMethodError: undefined method `call' for nil:NilClass
Did you mean?  caller
    find at org/jruby/RubyEnumerable.java:656
  <main> at -e:1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.