るりまサーチ (Ruby 2.5.0)

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

モジュール

キーワード

検索結果

Enumerable#take(n) -> Array (78367.0)

Enumerable オブジェクトの先頭から n 要素を配列として返します。

Enumerable オブジェクトの先頭から n 要素を配列として返します。

@param n 要素数を指定します。

//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take(3) # => [1, 2, 3]
//}

@see Array#take

Enumerable#take_while -> Enumerator (42370.0)

Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。

Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。
最初に偽になった要素の手前の要素までを配列として返します。

//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
//}

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

@see Array#take_while

Enumerable#take_while {|element| ... } -> Array (42370.0)

Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。

Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。
最初に偽になった要素の手前の要素までを配列として返します。

//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
//}

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

@see Array#take_while

Enumerator::Lazy#chunk {|elt| ... } -> Enumerator::Lazy (24046.0)

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

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

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

1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]], [true, [3]], [false, [4, 5...

Enumerator::Lazy#chunk(initial_state) {|elt, state| ... } -> Enumerator::Lazy (24046.0)

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

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

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

1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]], [true, [3]], [false, [4, 5...

絞り込み条件を変える

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

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

Enumerable#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], [...

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

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

Enumerable#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], [...

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

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

Enumerable#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...

Enumerator::Lazy#slice_before(initial_state) {|elt, state| bool } -> Enumerator::Lazy (24046.0)

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

Enumerable#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...

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

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

Enumerable#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...

絞り込み条件を変える

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

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

Enumerable#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]...