Actions
Feature #16425
openAdd Thread#dig
Feature #16425:
Add Thread#dig
Status:
Open
Assignee:
-
Target version:
-
Description
Thread
has #[]
method like as Array
, Hash
, Struct
and so on, but no #dig
.
For instance, PP::PPMethods#check_inspect_key
in pp.rb can be simplified with the combination of this method and safe navigation operator.
From
def check_inspect_key(id)
Thread.current[:__recursive_key__] &&
Thread.current[:__recursive_key__][:inspect] &&
Thread.current[:__recursive_key__][:inspect].include?(id)
end
To
def check_inspect_key(id)
Thread.current.dig(:__recursive_key__, :inspect)&.include?(id)
end
Actions