別のキーワード
種類
ライブラリ
クラス
-
ARGF
. class (60) - Array (249)
- CSV (72)
-
CSV
:: Row (12) -
CSV
:: Table (36) - Dir (158)
- Enumerator (182)
-
Enumerator
:: Lazy (183) -
Enumerator
:: Yielder (30) - File (24)
- Hash (182)
- IO (216)
- Matrix (196)
- Module (36)
- Object (72)
- PP (12)
- Pathname (75)
- Prime (24)
-
Prime
:: PseudoPrimeGenerator (48) -
REXML
:: Attributes (24) -
REXML
:: Element (24) -
REXML
:: Elements (24) -
REXML
:: XPath (12) - Range (40)
- Set (168)
- String (260)
- StringIO (100)
- Struct (48)
- Thread (12)
-
Thread
:: Queue (82) -
Thread
:: SizedQueue (46) - WIN32OLE (12)
-
WIN32OLE
_ EVENT (24) -
WIN32OLE
_ TYPE (12)
モジュール
- Enumerable (499)
- Kernel (121)
-
Net
:: HTTPHeader (72) - ObjectSpace (72)
- TSort (186)
オブジェクト
- ENV (72)
キーワード
-
$ CHILD _ STATUS (12) -
$ LAST _ PAREN _ MATCH (12) -
$ _ (12) -
$ stdin (12) - & (12)
- + (19)
- - (12)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - << (12)
- ARGF (12)
- ConditionVariable (12)
- DATA (12)
- Enumerator (12)
- Fiber (12)
- Lazy (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Open3 (12)
- Proc (12)
- Queue (12)
- Range (12)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
-
WIN32OLE
_ EVENT (12) -
WIN32OLE
_ VARIABLE (12) - [] (12)
- ^ (12)
-
append
_ features (12) - bytes (38)
- chars (24)
- children (16)
- 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 (70) -
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 (60) -
each
_ line (144) -
each
_ name (12) -
each
_ object (48) -
each
_ pair (72) -
each
_ slice (24) -
each
_ strongly _ connected _ component (46) -
each
_ strongly _ connected _ component _ from (46) -
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) - fnmatch (12)
- fnmatch? (12)
-
force
_ quotes? (12) - foreach (96)
- getoptlong (12)
-
grapheme
_ clusters (16) - handler= (12)
- index (36)
- inject (36)
-
inplace
_ mode (12) -
instance
_ method (12) - intersection (12)
- invert (12)
-
keep
_ if (24) - lambda (18)
- length (12)
- lines (38)
- map (24)
- map! (38)
-
memsize
_ of _ all (12) - merge (12)
- new (103)
- next (12)
-
next
_ values (12) -
ole
_ query _ interface (12) - open-uri (12)
- optparse (12)
- pack (21)
- pack テンプレート文字列 (12)
- parse (24)
-
peek
_ values (12) - pop (24)
- pos (12)
- pp (12)
- prime (12)
- proc (19)
- profile (6)
- push (12)
-
reachable
_ objects _ from (12) - reduce (36)
- rehash (12)
- reject! (24)
- replace (12)
-
respond
_ to? (12) -
reverse
_ each (52) - rewind (12)
-
rinda
/ rinda (12) - rss (12)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) - select! (24)
- seplist (12)
- shift (24)
- size (12)
-
slice
_ after (46) -
slice
_ before (60) -
slice
_ when (23) -
strongly
_ connected _ components (24) - subtract (12)
- sum (36)
- take (12)
-
take
_ while (24) - tell (12)
- test (24)
-
to
_ a (24) -
to
_ enum (48) -
to
_ h (19) -
to
_ proc (6) - tsort (36)
-
tsort
_ each (46) - union (12)
- unpack (12)
- upto (12)
-
webrick
/ cgi (12) -
with
_ index (48) -
with
_ object (24) - yaml (12)
- yield (12)
- zip (48)
- | (12)
- メソッド呼び出し(super・ブロック付き・yield) (12)
- 制御構造 (12)
- 手続きオブジェクトの挙動の詳細 (12)
検索結果
先頭5件
-
Enumerator
# each -> self (18194.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 (18194.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 (18194.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 (18194.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 (18174.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 (18174.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 (18158.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 (18158.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 (18148.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...