compact -> HashRuby 2.4.0 から[permalink][rdoc][edit]-
自身から value が nil のもの取り除いた Hash を生成して返します。
例hash = {a: 1, b: nil, c: 3} p hash.compact # => {:a=>1, :c=>3} p hash # => {:a=>1, :b=>nil, :c=>3}[SEE_ALSO] Hash#compact!, Array#compact
このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ
compact -> HashRuby 2.4.0 から[permalink][rdoc][edit]自身から value が nil のもの取り除いた Hash を生成して返します。
例hash = {a: 1, b: nil, c: 3}
p hash.compact # => {:a=>1, :c=>3}
p hash # => {:a=>1, :b=>nil, :c=>3}
[SEE_ALSO] Hash#compact!, Array#compact