るりまサーチ

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

別のキーワード

  1. array fill
  2. array sample
  3. array []
  4. array count
  5. array fetch

ライブラリ

検索結果

Hash#compact -> Hash (18165.0)

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

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


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

@see Array#compact...

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

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

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


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

@see Array#compact...