るりまサーチ

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Enumerable#compact -> Array (21006.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...

Enumerator::Lazy#to_enum(method = :each, *args) -> Enumerator::Lazy (15148.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum
は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...
...n.times { yield *val }
end
else
to_enum
(:repeat, n)
end
end
end

r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
#...

Enumerator::Lazy#to_enum(method = :each, *args) {|*args| block} -> Enumerator::Lazy (15148.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum
は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...
...n.times { yield *val }
end
else
to_enum
(:repeat, n)
end
end
end

r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
#...

Object#to_enum(method = :each, *args) -> Enumerator (15120.0)

Enumerator.new(self, method, *args) を返します。

...2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method_...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (15120.0)

Enumerator.new(self, method, *args) を返します。

...2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method_...

絞り込み条件を変える

Enumerator::Lazy#enum_for(method = :each, *args) -> Enumerator::Lazy (48.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum
は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...
...n.times { yield *val }
end
else
to_enum
(:repeat, n)
end
end
end

r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
#...

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (48.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum
は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...
...n.times { yield *val }
end
else
to_enum
(:repeat, n)
end
end
end

r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り値は
#...

Enumerator (34.0)

each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。 また、外部イテレータとしても使えます。

...each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。
また、外部イテレータとしても使えます。

Enumerable
モジュールは、 Module#include 先のクラスが持つ
each メソッドを元に様々なメソッドを提供し...
...#each_byte のような
異なる名前のイテレータについても each と同様に Enumerable の機能を利用できます。

Enumerator を生成するには Enumerator.newあるいは
Object#to_enum, Object#enum_for を利用します。また、一部の
イテレータはブロック...

Object#enum_for(method = :each, *args) -> Enumerator (20.0)

Enumerator.new(self, method, *args) を返します。

...2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method_...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (20.0)

Enumerator.new(self, method, *args) を返します。

...2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method_...

絞り込み条件を変える

<< 1 2 > >>