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

@davishmcclurg davishmcclurg 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
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
Loading
@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 issue May 28, 2019
…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
```
@davishmcclurg davishmcclurg deleted the nil-ifnone branch Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants