モジュール
- Enumerable (111)
検索結果
先頭5件
-
Enumerator
:: Lazy # filter {|item| . . . } -> Enumerator :: Lazy (32.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.find_all { |i| i.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:......step>>:find_all>
1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Enumerator
:: Lazy # find _ all {|item| . . . } -> Enumerator :: Lazy (32.0) -
Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#select と同じですが、配列ではなくEnumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.find_all { |i| i.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:......step>>:find_all>
1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerable#select... -
Hash
# filter -> Enumerator (29.0) -
key, value のペアについてブロックを評価し,真となるペアだけを含む ハッシュを生成して返します。
...った場合は、自身と select から生成した
Enumerator オブジェクトを返します。
//emlist[][ruby]{
h = { "a" => 100, "b" => 200, "c" => 300 }
h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300}
h.select {|k,v| v < 200} #=> {"a" => 100}
//}
@see Hash#select!, Hash#reject... -
Hash
# filter {|key , value| . . . } -> Hash (29.0) -
key, value のペアについてブロックを評価し,真となるペアだけを含む ハッシュを生成して返します。
...った場合は、自身と select から生成した
Enumerator オブジェクトを返します。
//emlist[][ruby]{
h = { "a" => 100, "b" => 200, "c" => 300 }
h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300}
h.select {|k,v| v < 200} #=> {"a" => 100}
//}
@see Hash#select!, Hash#reject... -
Enumerator
:: Lazy # eager -> Enumerator (27.0) -
自身を遅延評価しない Enumerator に変換して返します。
...ch.lazy
# select が遅延評価されるので終了する
p lazy_enum.class # => Enumerator::Lazy
p lazy_enum.select { |n| n.even? }.first(5)
# => [2, 4, 6, 8, 10]
# select が遅延評価されないので終了しない
enum = lazy_enum.eager
p enum.class # => Enumerator
p enum.select { |n| n.... -
Array
# reject -> Enumerator (25.0) -
各要素に対してブロックを評価し、 その値が偽であった要素を集めた新しい配列を返します。 条件を反転させた select です。
...を返します。
条件を反転させた select です。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# 偶数を除外する (奇数を集める)
[1, 2, 3, 4, 5, 6].reject {|i| i % 2 == 0 } # => [1, 3, 5]
//}
@see Array#select, Enumerable#reject......す。
条件を反転させた select です。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# 偶数を除外する (奇数を集める)
[1, 2, 3, 4, 5, 6].reject {|i| i % 2 == 0 } # => [1, 3, 5]
//}
@see Array#select, Enumerable#reject
@see Enumerabl... -
Array
# reject {|item| . . . } -> [object] (25.0) -
各要素に対してブロックを評価し、 その値が偽であった要素を集めた新しい配列を返します。 条件を反転させた select です。
...を返します。
条件を反転させた select です。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# 偶数を除外する (奇数を集める)
[1, 2, 3, 4, 5, 6].reject {|i| i % 2 == 0 } # => [1, 3, 5]
//}
@see Array#select, Enumerable#reject......す。
条件を反転させた select です。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# 偶数を除外する (奇数を集める)
[1, 2, 3, 4, 5, 6].reject {|i| i % 2 == 0 } # => [1, 3, 5]
//}
@see Array#select, Enumerable#reject
@see Enumerabl... -
Enumerable
# reject -> Enumerator (25.0) -
各要素に対してブロックを評価し、 その値が偽であった要素を集めた新しい配列を返します。 条件を反転させた select です。
...します。
条件を反転させた select です。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# 偶数を除外する (奇数を集める)
(1..6).reject {|i| i % 2 == 0 } # => [1, 3, 5]
//}
@see Enumerable#select, Array#reject
@see Enumerable#grep_... -
Enumerable
# reject {|item| . . . } -> [object] (25.0) -
各要素に対してブロックを評価し、 その値が偽であった要素を集めた新しい配列を返します。 条件を反転させた select です。
...します。
条件を反転させた select です。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# 偶数を除外する (奇数を集める)
(1..6).reject {|i| i % 2 == 0 } # => [1, 3, 5]
//}
@see Enumerable#select, Array#reject
@see Enumerable#grep_... -
Enumerable
# filter -> Enumerator (23.0) -
各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。
...# => #<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
# filter {|item| . . . } -> [object] (23.0) -
各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。
...# => #<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
# find _ all -> Enumerator (23.0) -
各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。
...# => #<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...