Skip to content

Ignore nil for ifnone argument in Enumerable#find#5726

Merged
kares merged 1 commit intojruby:masterfrom
davishmcclurg:nil-ifnone
May 6, 2019
Merged

Ignore nil for ifnone argument in Enumerable#find#5726
kares merged 1 commit intojruby:masterfrom
davishmcclurg:nil-ifnone

Conversation

@davishmcclurg
Copy link
Contributor

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
@kares kares added this to the JRuby 9.2.8.0 milestone May 6, 2019
eregon pushed a commit to ruby/spec that referenced this pull request 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 October 8, 2019 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants