るりまサーチ

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

別のキーワード

  1. _builtin assoc
  2. env assoc
  3. hash assoc
  4. array assoc

ライブラリ

検索結果

Hash#assoc(key) -> Array | nil (18120.0)

ハッシュが key をキーとして持つとき、見つかった要素のキーと値のペア を配列として返します。

...見つからなかった場合は、nil を返します。

@param key 検索するキー

//emlist[例][ruby]{
h = {"colors" => ["red", "blue", "green"],
"letters" => ["a", "b", "c" ]}
h.assoc("letters") #=> ["letters", ["a", "b", "c"]]
h.assoc("foo") #=> nil
//}



@see Array#assoc...

Hash#rassoc(value) -> Array | nil (6107.0)

ハッシュ内を検索して,引数 value と 一致する値を探します。

...とするサイズ 2 の配列を返します。
ない場合には nil を返します。

@param value 探索する値。

//emlist[例][ruby]{
a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"}
a.rassoc("two") #=> [2, "two"]
a.rassoc("four") #=> nil
//}

@see Hash#assoc, Array#rassoc...