るりまサーチ

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

別のキーワード

  1. _builtin to_a
  2. matrix to_a
  3. to_a
  4. dbm to_a
  5. argf.class to_a

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Range#%(s) -> Enumerator::ArithmeticSequence (21412.0)

範囲内の要素を s おきに繰り返します。

...す。

@param s 各ステップの大きさを数値で指定します。負の数を指定することもできます。
@return ブロックを指定した時は self を返します。
@return ブロックを指定しなかった時かつ数値の Range の時は Enumerator::ArithmeticSequence...
...を返します。
@return ブロックを指定しなかったその他の Range の時は Enumerator を返します。(例: String の Range)

//emlist[例][ruby]{
("a" .. "f").step(2) {|v| p v}
# => "a"
# "c"
# "e"
//}...

Enumerable#find_index -> Enumerator (15460.0)

条件に一致する最初の要素の位置を返します。

...@param val 位置を知りたいオブジェクトを指定します。

指定された val と == で等しい最初の要素の位置を返します。
等しい要素がひとつもなかった場合は nil を返します。

//emlist[例][ruby]{
(1..10).find_index(11) #=> nil
(1..10).find_ind...
...かった場合は nil を返します。

//emlist[例][ruby]{
(1..10).find_index {|i| i % 5 == 0 and i % 7 == 0 } #=> nil
(1..100).find_index {|i| i % 5 == 0 and i % 7 == 0 } #=> 34
//}

引数、ブロックのどちらも与えられなかった場合は、
Enumerator のインスタンス...

Enumerator::Lazy#slice_after {|elt| bool } -> Enumerator::Lazy (15312.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>

1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5...
...).force
# => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]
//}

@see Enumerable#slice_after...

Enumerator::Lazy#slice_after(pattern) -> Enumerator::Lazy (15312.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>

1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5...
...).force
# => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]
//}

@see Enumerable#slice_after...

Enumerator::Lazy#slice_before(pattern) -> Enumerator::Lazy (12406.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>

1.step.lazy.slice_before { |e| e % 3 == 0 }.take(...
...5).force
# => [[1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]]
//}

@see Enumerable#slice_before...

絞り込み条件を変える

Enumerator::Lazy#slice_when {|elt_before, elt_after| bool } -> Enumerator::Lazy (12336.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_when { |i, j| (i + j) % 5 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007fce84118348>:each>>

1.step.lazy.slice_when { |i, j| (i + j) %...
...5 == 0 }.take(5).force
# => [[1, 2], [3, 4, 5, 6, 7], [8, 9, 10, 11, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22]]
//}

@see Enumerable#slice_when...

Enumerable#find_all -> Enumerator (12318.0)

各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。

...クを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
(1..10).find_all # => #<Enumerator: 1..10:find_all>
(1..10).find_all { |i| i % 3 == 0 } # => [3, 6, 9]

[1,2,3,4,5].select # => #<Enumerator: [1, 2, 3, 4, 5]:select>
[1,2,3...
...,4,5].select { |num| num.even? } # => [2, 4]
//}

@see Enumerable#reject
@see Enumerable#grep...

Enumerable#minmax_by -> Enumerator (12318.0)

Enumerable オブジェクトの各要素をブロックに渡して評価し、その結果を <=> で比較して 最小の要素と最大の要素を要素とするサイズ 2 の配列を返します。

...Enumerable オブジェクトの各要素をブロックに渡して評価し、その結果を <=> で比較して
最小の要素と最大の要素を要素とするサイズ 2 の配列を返します。

該当する要素が複数存在する場合、どの要素を返すかは不定です。...
...numerable#minmax と Enumerable#minmax_by の
違いは sort と sort_by の違いと同じです。
詳細は Enumerable#sort_by を参照してください。

//emlist[例][ruby]{
a
= %w(albatross dog horse)
a
.minmax_by {|x| x.length } #=> ["dog", "albatross"]

[].minmax_by{} # => [nil, nil]
//...
...}

ブロックを省略した場合は Enumerator を返します。

@see Enumerable#sort_by...

Enumerable#partition -> Enumerator (12318.0)

各要素を、ブロックの条件を満たす要素と満たさない要素に分割します。 各要素に対してブロックを評価して、その値が真であった要素の配列と、 偽であった要素の配列の 2 つを配列に入れて返します。

...要素の配列と、
偽であった要素の配列の 2 つを配列に入れて返します。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0].partition {|i| i % 3 == 0 }
#=> [[9, 6, 3, 0], [10, 8, 7, 5, 4, 2, 1]]
//}...

Enumerator::Lazy#slice_before {|elt| bool } -> Enumerator::Lazy (12306.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>

1.step.lazy.slice_before { |e| e % 3 == 0 }.take(...
...5).force
# => [[1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]]
//}

@see Enumerable#slice_before...

絞り込み条件を変える

<< 1 2 3 ... > >>