るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method gets
  4. irb/input-method new
  5. matrix -

検索結果

Array#compact -> Array (18255.0)

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

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

//emlist[例][ruby]{
ary = [1, nil, 2, nil, 3, nil]
p ary.compact...
...#=> [1, 2, 3]
p ary #=> [1, nil, 2, nil, 3, nil]
ary.compact!
p ary #=> [1, 2, 3]
p ary.compact! #=> nil
//}...

Array#compact! -> self | nil (6255.0)

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

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

//emlist[例][ruby]{
ary = [1, nil, 2, nil, 3, nil]
p ary.compact...
...#=> [1, 2, 3]
p ary #=> [1, nil, 2, nil, 3, nil]
ary.compact!
p ary #=> [1, 2, 3]
p ary.compact! #=> nil
//}...