別のキーワード
ライブラリ
クラス
-
ARGF
. class (60) - Array (213)
- CSV (24)
-
CSV
:: Row (12) -
CSV
:: Table (36) - Dir (62)
- Enumerator (163)
-
Enumerator
:: Lazy (171) -
Enumerator
:: Yielder (30) - Hash (182)
- IO (192)
- Matrix (196)
- Module (36)
- Object (60)
- PP (12)
- Pathname (75)
- Prime (24)
-
Prime
:: PseudoPrimeGenerator (48) -
REXML
:: Attributes (24) -
REXML
:: Element (24) -
REXML
:: Elements (24) - Range (28)
- Set (144)
- String (260)
- StringIO (100)
- Struct (48)
- Thread (12)
-
Thread
:: Queue (82) -
Thread
:: SizedQueue (46) - WIN32OLE (12)
-
WIN32OLE
_ EVENT (12) -
WIN32OLE
_ TYPE (12)
モジュール
- Enumerable (499)
- Kernel (12)
-
Net
:: HTTPHeader (72) - TSort (93)
キーワード
- & (12)
- + (19)
- - (12)
- << (12)
- [] (12)
- ^ (12)
-
append
_ features (12) - bytes (38)
- chars (24)
- chmod (12)
- chunk (36)
-
chunk
_ while (12) - clear (12)
- close (10)
- closed? (10)
- codepoints (24)
- collect (24)
- collect! (38)
-
collect
_ concat (12) - count (36)
-
default
_ event _ sources (12) -
delete
_ if (24) - deq (24)
- difference (12)
- drop (12)
-
each
_ attribute (12) -
each
_ byte (72) -
each
_ capitalized _ name (12) -
each
_ char (48) -
each
_ child (38) -
each
_ codepoint (72) -
each
_ cons (24) -
each
_ element _ with _ attribute (12) -
each
_ element _ with _ text (12) -
each
_ entry (39) -
each
_ filename (12) -
each
_ grapheme _ cluster (16) -
each
_ header (12) -
each
_ index (24) -
each
_ key (36) -
each
_ line (144) -
each
_ name (12) -
each
_ pair (48) -
each
_ slice (24) -
each
_ strongly _ connected _ component (23) -
each
_ strongly _ connected _ component _ from (23) -
each
_ value (36) -
each
_ with _ index (72) -
each
_ with _ object (24) - eager (6)
- entries (12)
-
enum
_ for (48) -
extend
_ object (12) - feed (12)
- filter! (14)
-
find
_ index (36) - first (24)
-
flat
_ map (12) -
force
_ quotes? (12) -
grapheme
_ clusters (16) - handler= (12)
- index (36)
- inject (36)
-
inplace
_ mode (12) -
instance
_ method (12) - intersection (12)
- invert (12)
-
keep
_ if (24) - length (12)
- lines (38)
- map (24)
- map! (38)
- merge (12)
- next (12)
-
next
_ values (12) -
ole
_ query _ interface (12) - pack (21)
-
peek
_ values (12) - pop (24)
- pos (12)
- push (12)
- reduce (36)
- rehash (12)
- reject! (24)
- replace (12)
-
respond
_ to? (12) -
reverse
_ each (52) - rewind (12)
- select! (24)
- seplist (12)
- shift (24)
- size (12)
-
slice
_ after (46) -
slice
_ before (60) -
slice
_ when (23) -
strongly
_ connected _ components (12) - subtract (12)
- sum (36)
- take (12)
-
take
_ while (24) - tell (12)
-
to
_ a (24) -
to
_ enum (48) -
to
_ h (19) -
to
_ proc (6) - tsort (12)
-
tsort
_ each (23) - union (12)
- unpack (12)
- upto (12)
-
with
_ index (48) -
with
_ object (24) - yield (12)
- zip (48)
- | (12)
検索結果
先頭5件
-
Enumerator
# each -> self (18195.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 (18195.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 (18195.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 (18195.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_... -
Prime
# each(upper _ bound = nil , generator = EratosthenesGenerator . new) -> Enumerator (18175.0) -
全ての素数を順番に与えられたブロックに渡して評価します。
...。
//emlist[例][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,......素数を与えるべきではありません。
このメソッドは、素数列の外部イテレータを内部イテレータに変換してRubyらしいプログラミングを提供することが責務です。独自に素数性の保障するのはメソッドの責務ではありません......数とは限らない数列が発生します。
//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, Pr... -
Prime
# each(upper _ bound = nil , generator = EratosthenesGenerator . new) {|prime| . . . } -> object (18175.0) -
全ての素数を順番に与えられたブロックに渡して評価します。
...。
//emlist[例][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,......素数を与えるべきではありません。
このメソッドは、素数列の外部イテレータを内部イテレータに変換してRubyらしいプログラミングを提供することが責務です。独自に素数性の保障するのはメソッドの責務ではありません......数とは限らない数列が発生します。
//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, Pr... -
Hash
# each -> Enumerator (18159.0) -
ハッシュのキーと値を引数としてブロックを評価します。
...
each_pair は each のエイリアスです。
//emlist[例][ruby]{
{:a=>1, :b=>2}.each {|a| p a}
#=> [:a, 1]
# [:b, 2]
{:a=>1, :b=>2}.each {|k, v| p [k, v]}
#=> [:a, 1]
# [:b, 2]
p({:a=>1, :b=>2}.each_pair) # => #<Enumerator: {:a=>1, :b=>2}:each_pair>
//}
@see Hash#each_key,Hash#each_val... -
Hash
# each {|key , value| . . . } -> self (18159.0) -
ハッシュのキーと値を引数としてブロックを評価します。
...
each_pair は each のエイリアスです。
//emlist[例][ruby]{
{:a=>1, :b=>2}.each {|a| p a}
#=> [:a, 1]
# [:b, 2]
{:a=>1, :b=>2}.each {|k, v| p [k, v]}
#=> [:a, 1]
# [:b, 2]
p({:a=>1, :b=>2}.each_pair) # => #<Enumerator: {:a=>1, :b=>2}:each_pair>
//}
@see Hash#each_key,Hash#each_val... -
IO
# each(limit , chomp: false) -> Enumerator (18149.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...ープンされていなければ発生します。
//emlist[例: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line......: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1......is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: T...