るりまサーチ

最速Rubyリファレンスマニュアル検索!
9件ヒット [1-9件を表示] (0.030秒)

別のキーワード

  1. openssl public_key
  2. openssl public_key=
  3. _builtin each_key
  4. socket pf_key
  5. _builtin key?

クラス

検索結果

OpenStruct#dig(key, ...) -> object | nil (115.0)

self 以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し ます。途中のオブジェクトが nil であった場合は nil を返します。

...に参照して返し
ます。途中のオブジェクトが nil であった場合は nil を返します。

@param key キーを任意個指定します。

require 'ostruct'
address = OpenStruct.new('city' => "Anytown NC", 'zip' => 12345)
person = OpenStruct.new('name' => 'John Smith', 'a...
...ddress' => address)
person.dig(:address, 'zip') # => 12345
person.dig(:business_address, 'zip') # => nil

@see Array#dig, Hash#dig, Struct#dig...