[ruby-core:79052] [Ruby trunk Feature#13123] NilClass#dig

From: sawadatsuyoshi@...
Date: 2017-01-11 07:07:03 UTC
List: ruby-core #79052
Issue #13123 has been reported by Tsuyoshi Sawada.

----------------------------------------
Feature #13123: NilClass#dig
https://bugs.ruby-lang.org/issues/13123

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
We now have `Hash#dig`. We often have a variable that is either a hash or nil but we are not sure which. In such cases, it would be convenient if we can apply `dig` without conditioning on whether it is a hash or nil.

```ruby
h = {a: 1}
h.dig(:a) # => 1

h = nil
h.dig(:a) # => nil
```



-- 
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>

In This Thread

Prev Next