別のキーワード
ライブラリ
- ビルトイン (694)
- gdbm (12)
-
net
/ pop (48) - objspace (24)
- prime (48)
-
rexml
/ document (48) -
shell
/ builtin-command (6) -
shell
/ process-controller (6) - socket (24)
- thread (12)
- win32ole (36)
クラス
- Array (57)
- Enumerator (91)
-
Enumerator
:: Chain (7) -
Enumerator
:: Lazy (23) -
Enumerator
:: Yielder (24) - GDBM (12)
- Integer (12)
- Module (12)
-
Net
:: POP3 (12) -
Net
:: POPMail (36) - Object (72)
- Prime (24)
-
Prime
:: PseudoPrimeGenerator (12) -
REXML
:: Elements (24) -
REXML
:: Parent (24) -
Shell
:: Concat (6) -
Shell
:: ProcessController (6) - Socket (24)
- StopIteration (12)
- String (12)
- Thread (48)
-
Thread
:: Queue (36) -
Thread
:: SizedQueue (36) -
WIN32OLE
_ EVENT (12) -
WIN32OLE
_ PARAM (12) -
WIN32OLE
_ VARIABLE (12)
モジュール
- Enumerable (216)
- Kernel (12)
- ObjectSpace (72)
キーワード
-
$ stdin (12) - << (12)
- DATA (12)
-
NEWS for Ruby 2
. 3 . 0 (10) - [] (12)
- all (12)
-
chunk
_ while (12) - collect (12)
- count (12)
- default (12)
- deq (24)
-
each
_ active _ object (6) -
each
_ child (12) -
each
_ entry (12) -
each
_ object (48) -
each
_ prime (12) -
each
_ with _ object (24) - entries (12)
-
enum
_ for (24) -
extend
_ object (12) - feed (12)
- first (12)
- handler= (12)
- inject (48)
- join (24)
- mail (12)
-
memsize
_ of _ all (12) -
net
/ imap (12) - new (19)
- next (12)
- open (12)
-
os
_ each _ obj (12) - pack (21)
- pack テンプレート文字列 (12)
- pop (36)
-
reachable
_ objects _ from (12) - reduce (36)
- reject! (24)
-
respond
_ to? (12) - result (12)
-
ruby 1
. 6 feature (12) - shift (24)
-
slice
_ when (23) - start (12)
- sum (24)
-
tcp
_ server _ sockets (24) -
to
_ a (12) -
to
_ enum (24) - unpack (12)
- value (24)
-
with
_ index (12) -
with
_ object (24) - yield (12)
- zip (24)
- 制御構造 (12)
検索結果
先頭5件
- Enumerator
# each { . . . } -> object - Enumerator
# each(*args) { . . . } -> object - Prime
# each(upper _ bound = nil , generator = EratosthenesGenerator . new) {|prime| . . . } -> object - Prime
. each(upper _ bound = nil , generator = EratosthenesGenerator . new) {|prime| . . . } -> object - Enumerator
:: Chain # each(*args) { |*args| . . . } -> object
-
Enumerator
# each { . . . } -> object (18264.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"......scan).each(/\w+/).to_a # => ["Hello", "world"]
obj = Object.new
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 { |e......lm| elm } # => :method_returned
enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
Enumerator
# each(*args) { . . . } -> object (18264.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"......scan).each(/\w+/).to_a # => ["Hello", "world"]
obj = Object.new
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 { |e......lm| elm } # => :method_returned
enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
Prime
# each(upper _ bound = nil , generator = EratosthenesGenerator . new) {|prime| . . . } -> object (18250.0) -
全ての素数を順番に与えられたブロックに渡して評価します。
...例][ruby]{
require 'prime'
Prime.each(6){|prime| prime } # => 5
Prime.each(7){|prime| prime } # => 7
Prime.each(10){|prime| prime } # => 7
Prime.each(11){|prime| prime } # => 11
//}
//emlist[例: 30以下の双子素数][ruby]{
require 'prime'
Prime.each(30).each_cons(2).select{|p,r| r-p == 2}
#......ない数列が発生します。
//emlist[例][ruby]{
require 'prime'
Prime.each(50, Prime::Generator23.new) do |n|
p n #=> [2, 3, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49]
end
//}
@see Prime.each, Prime::EratosthenesGenerator, Prime::TrialDivisionGenerator, Prime::Generator2... -
Prime
. each(upper _ bound = nil , generator = EratosthenesGenerator . new) {|prime| . . . } -> object (18224.0) -
Prime.instance.each と同じです。
...Prime.instance.each と同じです。
@param upper_bound 任意の正の整数を指定します。列挙の上界です。
nil が与えられた場合は無限に列挙し続けます。
@param generator 素数生成器のインスタンスを指定します。
@return ブ......ロックの最後に評価された値を返します。
ブロックが与えられなかった場合は、Enumerator と互換性のある外部イテレータを返します。
@see Prime#each... -
Enumerator
:: Chain # each(*args) { |*args| . . . } -> object (18218.0) -
まず最初の繰り返し可能なオブジェクトの each メソッドを args 引数とともに呼び出した後、続く繰り返し可能なオブジェクト も同様に呼び出します。
...まず最初の繰り返し可能なオブジェクトの each メソッドを
args 引数とともに呼び出した後、続く繰り返し可能なオブジェクト
も同様に呼び出します。
ブロックが渡されない場合は Enumerator を返します。... -
REXML
:: Parent # each {|object| . . . } -> () (18204.0) -
各子ノードに対しブロックを呼び出します。
各子ノードに対しブロックを呼び出します。
ブロックを省略した場合は Enumerator を返します。 -
Prime
:: PseudoPrimeGenerator # each {|prime| . . . } -> object (18202.0) -
素数を与えられたブロックに渡して評価します。
素数を与えられたブロックに渡して評価します。 -
Shell
:: Concat # each(rs = nil) {|job| . . . } (18201.0) -
@todo
@todo -
ObjectSpace
. # each _ object {|object| . . . } -> Integer (15340.0) -
指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。
...指定された klass と Object#kind_of? の関係にある全ての
オブジェクトに対して繰り返します。引数が省略された時には全てのオブ
ジェクトに対して繰り返します。
繰り返した数を返します。
ブロックが与えられなかった場合......emlist[例: ブロックなし][ruby]{
p ObjectSpace.each_object
# => #<Enumerator: ObjectSpace:each_object(false)>
//}
//emlist[例: 全てのオブジェクトを扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"......}
//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")
count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"
# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count:... -
ObjectSpace
. # each _ object(klass) {|object| . . . } -> Integer (15340.0) -
指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。
...指定された klass と Object#kind_of? の関係にある全ての
オブジェクトに対して繰り返します。引数が省略された時には全てのオブ
ジェクトに対して繰り返します。
繰り返した数を返します。
ブロックが与えられなかった場合......emlist[例: ブロックなし][ruby]{
p ObjectSpace.each_object
# => #<Enumerator: ObjectSpace:each_object(false)>
//}
//emlist[例: 全てのオブジェクトを扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"......}
//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")
count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"
# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count:...