ライブラリ
クラス
-
ARGF
. class (226) - Addrinfo (24)
- Array (569)
- CSV (24)
- Date (48)
- Dir (99)
- Enumerator (212)
-
Enumerator
:: ArithmeticSequence (98) -
Enumerator
:: Chain (42) -
Enumerator
:: Lazy (429) -
Enumerator
:: Yielder (30) -
Etc
:: Group (24) -
Etc
:: Passwd (24) -
Gem
:: SourceIndex (24) - Hash (241)
- IO (286)
- Integer (96)
- Matrix (200)
- Numeric (93)
- Object (77)
- OpenStruct (24)
- Pathname (126)
- Prime (48)
-
Prime
:: PseudoPrimeGenerator (84) -
Psych
:: Nodes :: Node (24) -
REXML
:: Parent (96) - Range (97)
- StopIteration (12)
- String (208)
- StringIO (176)
- Struct (43)
- Vector (88)
-
Zlib
:: GzipReader (72)
モジュール
- Enumerable (789)
- Find (24)
- Kernel (60)
- ObjectSpace (48)
- TSort (132)
オブジェクト
- ENV (268)
-
Readline
:: HISTORY (24)
キーワード
- % (14)
- + (7)
- << (12)
- == (7)
- ArithmeticSequence (7)
- Chain (7)
- Enumerable (12)
- Fiber (12)
- Lazy (12)
-
NEWS for Ruby 2
. 0 . 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
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Ruby用語集 (12)
- Yielder (12)
- ascend (24)
- begin (7)
- bsearch (48)
-
bsearch
_ index (20) - build (24)
- bytes (28)
- chain (7)
- chars (28)
- chunk (36)
-
chunk
_ while (21) - codepoints (42)
- collect (84)
- collect! (40)
- collect2 (12)
-
collect
_ concat (36) - combination (24)
- combine (16)
- compact (4)
- cycle (48)
-
delete
_ if (72) - descend (24)
- detect (24)
- downto (48)
- drop (12)
-
drop
_ while (60) - each (556)
- each2 (12)
-
each
_ byte (96) -
each
_ char (84) -
each
_ child (87) -
each
_ codepoint (96) -
each
_ cons (24) -
each
_ entry (30) -
each
_ grapheme _ cluster (16) -
each
_ index (48) -
each
_ key (36) -
each
_ line (216) -
each
_ object (48) -
each
_ pair (72) -
each
_ prime (24) -
each
_ slice (24) -
each
_ strongly _ connected _ component (44) -
each
_ strongly _ connected _ component _ from (44) -
each
_ value (36) -
each
_ with _ index (72) -
each
_ with _ object (24) - eager (6)
- end (7)
-
enum
_ for (48) -
exclude
_ end? (7) - feed (12)
- filter (56)
- filter! (42)
-
filter
_ map (18) - find (72)
-
find
_ all (36) -
find
_ index (108) - first (14)
-
flat
_ map (36) - force (12)
- foreach (120)
- grep (12)
-
grep
_ v (10) -
group
_ by (24) - gsub (84)
- gsub! (48)
- hash (7)
- index (72)
- inspect (14)
-
keep
_ if (48) - last (14)
- lazy (24)
- lines (98)
- loop (24)
- map (84)
- map! (40)
-
max
_ by (48) -
min
_ by (48) -
minmax
_ by (24) - new (38)
- next (12)
-
next
_ values (12) - partition (24)
- peek (12)
-
peek
_ values (12) - permutation (24)
- produce (6)
- reject (84)
- reject! (72)
-
repeated
_ combination (24) -
repeated
_ permutation (24) - result (12)
-
reverse
_ each (40) - rewind (31)
- rindex (36)
-
ruby 1
. 9 feature (12) - select (96)
- select! (72)
- size (26)
-
slice
_ after (46) -
slice
_ before (60) -
slice
_ when (23) -
sort
_ by (24) -
sort
_ by! (12) - step (143)
- take (12)
-
take
_ while (72) - then (14)
- times (24)
-
to
_ enum (48) -
to
_ proc (6) -
transform
_ keys (20) -
transform
_ keys! (20) -
transform
_ values (18) -
transform
_ values! (18) -
tsort
_ each (44) - uniq (18)
- upto (36)
-
with
_ index (60) -
with
_ object (48) - yield (12)
-
yield
_ self (15) - zip (24)
検索結果
先頭5件
-
Enumerator (44024.0)
-
each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。 また、外部イテレータとしても使えます。
...each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。
また、外部イテレータとしても使えます。
Enumerable モジュールは、 Module#include 先のクラスが持つ
each メソッドを元に様々なメソッドを提供し......されます。
Enumerator を介することにより String#each_byte のような
異なる名前のイテレータについても each と同様に Enumerable の機能を利用できます。
Enumerator を生成するには Enumerator.newあるいは
Object#to_enum, Object#enum_for を利用......します。また、一部の
イテレータはブロックを渡さずに呼び出すと繰り返しを実行する代わりに
enumerator を生成して返します。
=== 注意
外部イテレータとしての機能は Fiber を用いて実装されているため Fiber と同じ制限が... -
Enumerator
. new(size=nil) {|y| . . . } -> Enumerator (27265.0) -
Enumerator オブジェクトを生成して返します。与えられたブロックは Enumerator::Yielder オブジェクトを 引数として実行されます。
...
Enumerator オブジェクトを生成して返します。与えられたブロックは Enumerator::Yielder オブジェクトを
引数として実行されます。
生成された Enumerator オブジェクトに対して each を呼ぶと、この生成時に指定されたブロックを......
new に渡されたブロックが終了した時点で each の繰り返しが終わります。
このときのブロックの返り値が each の返り値となります。
@param size 生成する Enumerator オブジェクトの要素数を指定します。
Integer、Float::INF......INITY、Proc オブジェク
ト、nil のいずれかを指定します。Enumerator#size の実
行時に参照されます。
//emlist[例][ruby]{
enum = Enumerator.new{|y|
(1..10).each{|i|
y << i if i % 5 == 0
}
}
enum.each{|i| p i }
#=> 5
# 10
fib = Enumer... -
Enumerator
. new(obj , method = :each , *args) -> Enumerator (27215.0) -
オブジェクト obj について、 each の代わりに method という 名前のメソッドを使って繰り返すオブジェクトを生成して返します。 args を指定すると、 method の呼び出し時に渡されます。
...method イテレータメソッドの名前を表すシンボルまたは文字列
@param args イテレータメソッドの呼び出しに渡す任意個の引数
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new(str, :each_byte)
p enum.map {|b| '%02x' % b } # => ["78", "79", "7a"]
//}... -
Enumerator
# with _ index(offset = 0) -> Enumerator (27213.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|......にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。... -
Enumerator
# next _ values -> Array (27124.0) -
「次」のオブジェクトを配列で返します。
...ェクトを配列で返します。
Enumerator#next とほぼ同様の挙動をします。終端まで到達した場合は
StopIteration 例外を発生させます。
このメソッドは、
yield
と
yield nil
を区別するために使えます。
next メソッドによる外部列......each_line のようにおおもとの列挙メカニズムが副作用を
伴っている場合には影響があり得ます。
//emlist[例: next と next_values の違いを][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
yield nil
yield [1, 2]
end
e = o.to_enum
p e.next_val......e.next_values
p e.next_values
p e.next_values
p e.next_values
e = o.to_enum
p e.next
p e.next
p e.next
p e.next
p e.next
## yield args next_values next
# yield [] nil
# yield 1 [1] 1
# yield 1, 2 [1, 2] [1, 2]
# yield nil... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (27113.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|......にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。... -
Enumerator
# next -> object (27106.0) -
「次」のオブジェクトを返します。
...す。
列挙が既に最後へ到達している場合は、
StopIteration 例外を発生します。このとき列挙状態は変化しません。
つまりもう一度 next を呼ぶと再び例外が発生します。
next メソッドによる外部列挙の状態は他のイテレータメ......だし、 IO#each_line のようにおおもとの列挙メカニズムが副作用を
伴っている場合には影響があり得ます。
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#rewind
//emlist[例1][ruby]{
str = "xyz"
enum = str.each_byte
s......uts enum.next
end
# => 120
# 121
# 122
//}
//emlist[例2][ruby]{
str = "xyz"
enum = str.each_byte
begin
puts enum.next while true
rescue StopIteration
puts "iteration reached at end"
end
# => 120
# 121
# 122
# iteration reached at end
puts enum.next... -
Enumerator
# rewind -> self (27106.0) -
列挙状態を巻き戻します。
...
next メソッドによる外部列挙の状態を最初まで巻き戻します。 self を返します。
内包するオブジェクトが rewind メソッドを持つとき(respond_to?(:rewind) に
真を返すとき) は、その rewind メソッドを呼び出します。
@see Enumerator#n......ext
//emlist[例][ruby]{
str = "xyz"
enum = str.each_byte
p enum.next # => 120
p enum.next # => 121
enum.rewind
p enum.next # => 120
//}... -
NEWS for Ruby 2
. 6 . 0 (26096.0) -
NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.6.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......トは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 2.5.0 以降の変更
=== 言語仕様の変更
* $SAFE はプロセスグローバルで扱われることになると共に、0以外を設定した後に0に戻せるようになりました。 14......Dir#children 追加 13969
* Enumerable
* 新規メソッド
* Enumerable#chain はレシーバと引数のそれぞれの要素を順番にイテレートする
Enumerator::Chain オブジェクトを返します。 15144
* 変更されたメソッド
* Enumerable#to_... -
NEWS for Ruby 2
. 7 . 0 (26090.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.7.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 2.6.0 以降の変更
=== 言語仕様の変更
==== パターンマッチ
* パターンマッチが実験的機能として導入されました。 14912
//emlist[][ruby]{
case [0, [1, 2, 3]]
in [a, [b......15323
* Enumerable#tallyが追加されました。 11076
//emlist[Enumerable#filter_map][ruby]{
[1, 2, 3].filter_map {|x| x.odd? ? x.to_s : nil } #=> ["1", "3"]
//}
//emlist[Enumerable#tally][ruby]{
["A", "B", "C", "B", "A"].tally #=> {"A"=>2, "B"=>2, "C"=>1}
//}
* Enumerator
* 新規...