[#91458] [Ruby trunk Feature#4475] default variable name for parameter — matz@...
Issue #4475 has been updated by matz (Yukihiro Matsumoto).
3 messages
2019/02/07
[ruby-core:91542] [Ruby trunk Feature#7394] Enumerable#find ifnone parameter could be non-callable
From:
nobu@...
Date:
2019-02-14 04:44:47 UTC
List:
ruby-core #91542
Issue #7394 has been updated by nobu (Nobuyoshi Nakada).
Description updated
Currently, it is not able to distinguish from the case a hash is given as an ordinal argument.
So there still is a possibility to break a compatibility.
----------------------------------------
Feature #7394: Enumerable#find ifnone parameter could be non-callable
https://bugs.ruby-lang.org/issues/7394#change-76805
* Author: zzak (Zachary Scott)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version:
----------------------------------------
from github:
https://github.com/ruby/ruby/pull/186
In trunk the `Enumerable#find` method `ifnone` parameter has to be callable or `nil`. I found that sometimes I want to return a simple value without wrapping it in a proc. This pull request adds support for non-callable defaults when no items match.
```ruby
a = [1, 2, 3]
```
The current behavior
```ruby
a.find(proc { :foo }) { |x| x > 3 } #=> :foo
```
With patch
```ruby
a.find(0) { |x| x > 3 } #=> 0
```
---Files--------------------------------
enumerable_find_noncallable.patch (3.45 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>