るりまサーチ

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

別のキーワード

  1. _builtin nil?
  2. object nil?
  3. nilclass nil?
  4. object nil
  5. _builtin nil

ライブラリ

クラス

モジュール

検索結果

Array#compact -> Array (18243.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
//}...

Hash#compact -> Hash (18225.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...

Enumerable#compact -> Array (18135.0)

self から nil を取り除いた配列を生成して返します。

...self から nil を取り除いた配列を生成して返します。

//emlist[][ruby]{
def with_nils
yield 1
yield 2
yield nil
yield 3
end

to_enum(:with_nils).compact # => [1, 2, 3]
//}

@see Array#compact...

Array#compact! -> self | nil (6343.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
//}...

Hash#compact! -> self | nil (6325.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...

絞り込み条件を変える

GC.verify_compaction_references(toward: nil, double_heap: nil) -> Hash (6320.0)

コンパクションの参照の一貫性を検証します。

...ークスタックにプッシュされて、
SEGV が起きるでしょう。

@param toward nil か :empty を指定します。
@param double_heap ヒープサイズを2倍にするかどうかを真偽値で指定します。

@return GC.compact の返り値と同じです。

@see GC.compact...

Enumerator::Lazy.new(obj, size=nil) {|yielder, *values| ... } -> Enumerator::Lazy (107.0)

Lazy Enumerator を作成します。Enumerator::Lazy#force メソッドなどに よって列挙が実行されたとき、objのeachメソッドが実行され、値が一つずつ ブロックに渡されます。ブロックは、yielder を使って最終的に yield される値を 指定できます。

...//emlist[Enumerable#filter_map と、その遅延評価版を定義する例][ruby]{
module Enumerable
def filter_map(&block)
map(&block).compact
end
end

class Enumerator::Lazy
def filter_map
Lazy.new(self) do |yielder, *values|
result = yield *values
yielder << result i...

NEWS for Ruby 2.7.0 (78.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...で**nilと書くことで、このメソッドがキーワードを
受け取らないことを明示できるようになりました。このようなメソッドを
キーワード引数付きで呼び出すとArgumentErrorになります。 14183

//emlist[][ruby]{
def foo(h, **nil); en...
...d; foo(key: 1) # ArgumentError
def foo(h, **nil); end; foo(**{key: 1}) # ArgumentError
def foo(h, **nil); end; foo("str" => 1) # ArgumentError
def foo(h, **nil); end; foo({key: 1}) # OK
def foo(h, **nil); end; foo({"str" => 1}) # OK
//}

* キーワード引数を受け取らない...
...ンを受け付けるように
なりました。 15751

* GC
* 新規メソッド
* ヒープをコンパクションするGC.compactメソッドが追加されました。
このメソッドはヒープの生きているオブジェクトをコンパクションして...

NEWS for Ruby 3.1.0 (66.0)

NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...< A; end
A.subclasses #=> [D, B]
B.subclasses #=> [C]
C.subclasses #=> []
//}

* Enumerable
* 新規メソッド
* Enumerable#compactが追加されました。 17312
* Enumerable#tallyがカウント集計用のハッシュオブジェクトを任意で渡せるように...
...ons Enumerable#each_slice][ruby]{
[1, 2, 3].each_cons(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]

[1, 2, 3].each_slice(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]
//}

* Enumerator::Lazy
* 新規メソッド
* Enumerator::Lazy#compact が追加されました。 17312

* File
* 変更された...
...unctionが引数を返すようになりました。引数が1つでも渡されている場合、それが返されます。引数なしの場合、nilが返されます。複数の引数を渡した場合、それらを要素に持つ配列が返されます。 12495

* Process
* 新規メ...

NEWS for Ruby 3.0.0 (36.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...Fiber#transfer is relaxed. 17221
* GC
* GC.auto_compact= and GC.auto_compact have been added to control when compaction runs. Setting `auto_compact=` to `true` will cause compaction to occur during major collections. At the moment, compaction adds significant overhead to major collections, s...
...da's arity check.
* When writing to STDOUT redirected to a closed pipe, no broken pipe error message will be shown now. 14413
* `TRUE`/`FALSE`/`NIL` constants are no longer defined.
* Integer#zero? overrides Numeric#zero? for optimization. 16961
* Enumerable#grep and Enumerable#grep_v when...
...e improvements of JIT-ed code
* Microarchitectural optimizations
* Native functions shared by multiple methods are deduplicated on JIT compaction.
* Decrease code size of hot paths by some optimizations and partitioning cold paths.
* Instance variables
* Eliminate som...

絞り込み条件を変える

NEWS for Ruby 2.4.0 (24.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...け付けるようになりました。
half には :even, :up, :down が指定可能です。 12548 12958 12953

* Hash
* Hash#compact, Hash#compact! を追加 11818
* Hash#transform_values Hash#transform_values! を追加 12512

* Integer
* Fixnum と Bignum は Integer に...
...SCIIのみ変換したい場合です。国際化ドメイン名の処理はよい例です。

* TRUE / FALSE / NIL
これらは廃止されました。12574
true / false / nil を使用してください。

=== 標準添付ライブラリの互換性(機能追加とバグ修正を除く...