るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

Enumerator::Yielder#yield(*object) -> () (21162.0)

Enumerator.new で使うメソッドです。

...れた Enumerator オブジェクトの each メソッドを呼ぶと
Enumerator::Yielder オブジェクトが渡されたブロックが実行され、
ブロック内の yield メソッドが呼ばれるたびに each に渡された
ブロックが yield メソッドに渡された値ととも...
...に繰り返されます。

//emlist[例][ruby]{
enum = Enumerator.new do |y|
y.yield 1, 2, 3
end


enum.each do |x, y, z|
p [x, y, z]
end

# => [1, 2, 3]
//}...

Enumerator#each -> self (18249.0)

生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。

...引数

//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"

enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"...
...# "Ruby"
# "Hacker"
//}

//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # =>...
...ew

def obj.each_arg(a, b=:b, *rest)
yield
a
yield
b
yield
rest
:method_returned
end


enum = obj.to_enum :each_arg, :a, :x

enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned

enum.each(:y, :z).to_...

Enumerator#each {...} -> object (18249.0)

生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。

...引数

//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"

enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"...
...# "Ruby"
# "Hacker"
//}

//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # =>...
...ew

def obj.each_arg(a, b=:b, *rest)
yield
a
yield
b
yield
rest
:method_returned
end


enum = obj.to_enum :each_arg, :a, :x

enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned

enum.each(:y, :z).to_...

Enumerator#each(*args) -> Enumerator (18249.0)

生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。

...引数

//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"

enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"...
...# "Ruby"
# "Hacker"
//}

//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # =>...
...ew

def obj.each_arg(a, b=:b, *rest)
yield
a
yield
b
yield
rest
:method_returned
end


enum = obj.to_enum :each_arg, :a, :x

enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned

enum.each(:y, :z).to_...

Enumerator#each(*args) {...} -> object (18249.0)

生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。

...引数

//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"

enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"...
...# "Ruby"
# "Hacker"
//}

//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # =>...
...ew

def obj.each_arg(a, b=:b, *rest)
yield
a
yield
b
yield
rest
:method_returned
end


enum = obj.to_enum :each_arg, :a, :x

enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned

enum.each(:y, :z).to_...

絞り込み条件を変える

Enumerable#each_entry -> Enumerator (6151.0)

ブロックを各要素に一度ずつ適用します。

...数の値が渡された場合はブロックには配列として渡されます。

//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield
1
yield
1,2
end

end

Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}

ブロックを省略した場合は Enumerator...

Enumerable#each_entry {|obj| block} -> self (6151.0)

ブロックを各要素に一度ずつ適用します。

...数の値が渡された場合はブロックには配列として渡されます。

//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield
1
yield
1,2
end

end

Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}

ブロックを省略した場合は Enumerator...

Enumerator::Yielder#to_proc -> Proc (3055.0)

Enumerator.new で使うメソッドです。

...ator::Yielder#yield に渡す Proc を返します。
これは Enumerator::Yielder オブジェクトを他のメソッドにブロック引数と
して直接渡すために使えます。

//emlist[例][ruby]{
text = <<-END
Hello
こんにちは
END


enum = Enumerator.new do |y|
text.each_line(...
...&y)
end

enum.each do |line|
p line
end

# => "Hello\n"
# "こんにちは\n"
//}...

Enumerator::Yielder#<<(object) -> () (3043.0)

Enumerator.new で使うメソッドです。

...ェクトの each メソッドを呼ぶと
Enumerator::Yielder オブジェクトが渡されたブロックが実行され、
ブロック内の << が呼ばれるたびに each に渡されたブロックが
<< に渡された値とともに繰り返されます。

//emlist[例][ruby]{
enum = Enu...
...merator.new do |y|
y << 1
y << 2
y << 3
end


enum.each do |v|
p v
end

# => 1
# 2
# 3
//}...
<< 1 2 3 > >>