るりまサーチ

最速Rubyリファレンスマニュアル検索!
90件ヒット [1-90件を表示] (0.039秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

キーワード

検索結果

Enumerator::Lazy#zip(*lists) -> Enumerator::Lazy (21261.0)

Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

...merable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip
同じ挙動になります。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enu...
...merator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>

1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}

@see Enumerable#zip...

Enumerator::Lazy#zip(*lists) {|v1, v2, ...| ... } -> nil (21161.0)

Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

...merable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip
同じ挙動になります。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enu...
...merator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>

1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}

@see Enumerable#zip...

Array#zip(*lists) -> [[object]] (21133.0)

自身と引数に渡した配列の各要素からなる配列の配列を生成して返します。 生成される配列の要素数は self の要素数と同じです。

...ブジェクトを指定した場合は to_ary メソッドによ
る暗黙の型変換を試みます。to_ary メソッドに応答できない場
合は each メソッドによる暗黙の型変換を試みます。

@raise TypeError 引数に配列以外の(暗黙の型...
...ist[例][ruby]{
p [1,2,3].zip([4,5,6], [7,8,9])
# => [[1, 4, 7], [2, 5, 8], [3, 6, 9]]

p [1,2].zip([:a,:b,:c], [:A,:B,:C,:D])
# => a, :A], [2, :b, :B

p [1,2,3,4,5].zip([:a,:b,:c], [:A,:B,:C,:D])
# => [[1, :a, :A], [2, :b, :B],
# [3, :c, :C], [4, nil, :D], [5, nil, nil]]

p [1,2,3].zip([4,5,6],...
...[7,8,9]) { |ary| p ary }
# => [1, 4, 7]
# [2, 5, 8]
# [3, 6, 9]
# nil
//}...

Array#zip(*lists) {|v1, v2, ...| ...} -> nil (21133.0)

自身と引数に渡した配列の各要素からなる配列の配列を生成して返します。 生成される配列の要素数は self の要素数と同じです。

...ブジェクトを指定した場合は to_ary メソッドによ
る暗黙の型変換を試みます。to_ary メソッドに応答できない場
合は each メソッドによる暗黙の型変換を試みます。

@raise TypeError 引数に配列以外の(暗黙の型...
...ist[例][ruby]{
p [1,2,3].zip([4,5,6], [7,8,9])
# => [[1, 4, 7], [2, 5, 8], [3, 6, 9]]

p [1,2].zip([:a,:b,:c], [:A,:B,:C,:D])
# => a, :A], [2, :b, :B

p [1,2,3,4,5].zip([:a,:b,:c], [:A,:B,:C,:D])
# => [[1, :a, :A], [2, :b, :B],
# [3, :c, :C], [4, nil, :D], [5, nil, nil]]

p [1,2,3].zip([4,5,6],...
...[7,8,9]) { |ary| p ary }
# => [1, 4, 7]
# [2, 5, 8]
# [3, 6, 9]
# nil
//}...

Enumerable#lazy -> Enumerator::Lazy (6237.0)

自身を lazy な Enumerator に変換したものを返します。

...自身を lazy な Enumerator に変換したものを返します。

この Enumerator は、以下のメソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。

* map/collect
* flat_map/collect_concat
* select/find_all
*...
...reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さないケースのみlazy)
* cycle (※一貫性のため、ブロックを渡さないケースのみlazy)

以下はピタゴラス数 (a**2 + b**2 = c**2 を満たす自然数 a, b, c の...
...//emlist[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat_map {|z|
(1..z).flat_map {|x|
(x..z).select {|y|
x**2 + y**2 == z**2
}.map {|y|
[x, y, z]
}
}
}
end
# 最初の10個のピタゴラス数を表示する
p pythagorean_triples.t...

絞り込み条件を変える

Struct#deconstruct_keys(array_of_names) -> Hash (6131.0)

self のメンバの名前と値の組を Hash で返します。

...ray_of_names 返り値に含めるメンバの名前の配列を指定します。nil の場合は全てのメンバを意味します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
h = joe.deconstruct_keys([:zip,...
...:address])
h # => {:zip=>12345, :address=>"123 Maple, Anytown NC"}

# 引数が nil の場合は全てのメンバを返します。
h = joe.deconstruct_keys(nil)
h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}

[注意] 本メソッドの記述は Struct の...

Enumerator::Lazy#take_while -> Enumerator::Lazy (3131.0)

Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。

...rator::Lazy を返します。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>

1.step.lazy.zip(('a'..'z').cycle).take_...
...while { |e| e.first < 100_000 }.force.last(5)
# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}

@see Enumerable#take_while...

Enumerator::Lazy#take_while {|item| ... } -> Enumerator::Lazy (3131.0)

Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。

...rator::Lazy を返します。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>

1.step.lazy.zip(('a'..'z').cycle).take_...
...while { |e| e.first < 100_000 }.force.last(5)
# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}

@see Enumerable#take_while...