るりまサーチ

最速Rubyリファレンスマニュアル検索!
9件ヒット [1-9件を表示] (0.057秒)
トップページ > クエリ:Hash#key[x] > クエリ:keep_if[x] > クエリ:assoc[x] > クエリ:delete[x] > クエリ:shift[x] > クラス:OpenStruct[x]

別のキーワード

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

ライブラリ

検索結果

OpenStruct#dig(key, ...) -> object | nil (114.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', 'address' => address)
person.dig(:address,...
...'zip') # => 12345
person.dig(:business_address, 'zip') # => nil

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