るりまサーチ

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

別のキーワード

  1. _builtin to_h
  2. hash to_h
  3. env to_h
  4. struct to_h
  5. array to_h

ライブラリ

クラス

検索結果

Hash#compact! -> self | nil (18229.0)

compact は自身から value が nil のもの取り除いた Hash を生成して返します。 compact! は自身から破壊的に value が nil のものを取り除き、変更が行われた場合は self を、そうでなければ nil を返します。

...e が nil のもの取り除いた Hash を生成して返します。 compact! は自身から破壊的に value が nil のものを取り除き、変更が行われた場合は self を、そうでなければ nil を返します。


//emlist[例][ruby]{
h
ash = {a: 1, b: nil, c: 3}
p hash.compac...
...t #=> {:a=>1, :c=>3}
p hash #=> {:a=>1, :b=>nil, :c=>3}
h
ash.compact!
h
ash #=> {:a=>1, :c=>3}
p hash.compact! #=> nil
//}

@see Array#compact...