Project

General

Profile

Actions

Feature #13123

closed

NilClass#dig

Added by sawa (Tsuyoshi Sawada) over 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:79052]

Description

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.

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

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

Also available in: Atom PDF