クラス
- Enumerator (155)
-
Enumerator
:: Chain (6) -
Enumerator
:: Lazy (11) -
Enumerator
:: Yielder (27) - IO (154)
- Object (44)
- OpenStruct (22)
- Pathname (70)
- Prime (44)
-
Prime
:: PseudoPrimeGenerator (44) - StopIteration (11)
- StringIO (94)
- Struct (78)
モジュール
- Enumerable (44)
- Kernel (18)
- ObjectSpace (44)
キーワード
- << (11)
- Enumerator (11)
- Fiber (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Ruby用語集 (11)
- Yielder (11)
- ascend (22)
- bytes (14)
- descend (22)
- each (198)
-
each
_ byte (22) -
each
_ char (22) -
each
_ entry (26) -
each
_ line (88) -
each
_ object (44) -
each
_ pair (44) -
each
_ with _ index (44) -
enum
_ for (22) - feed (11)
- filter (12)
- find (22)
- lines (14)
- loop (18)
-
next
_ values (11) - optparse (11)
-
peek
_ values (11) - produce (5)
- result (11)
-
ruby 1
. 9 feature (11) - select (22)
- size (11)
-
to
_ enum (22) -
to
_ proc (5) -
with
_ index (44) -
with
_ object (22) - yield (11)
検索結果
先頭5件
-
Enumerator
# feed(obj) -> nil (9028.0) -
Enumerator 内部の yield が返す値を設定します。
...
Enumerator 内部の yield が返す値を設定します。
これで値を設定しなかった場合は yield は nil を返します。
この値は内部で yield された時点でクリアされます。
//emlist[例][ruby]{
# (1), (2), ... (10) の順に実行される
o = Object.new
def......= o.to_enum
e.next # (1)
e.feed "foo" # (3)
e.next # (4)
e.next # (7)
# (10)
//}
@param obj Enumerator 内部の yield が返す値
@raise TypeError すでに値をこのメソッドでセットしている場合に発生します... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (9025.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] }......ータに従って、要素にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにその... -
Enumerator
# with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (9025.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...った場合は、上で説明した繰り返しを実行し、
最後に obj を返す Enumerator を返します。
//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object(... -
Enumerator
# size -> Integer | Float :: INFINITY | nil (9024.0) -
self の要素数を返します。
...self の要素数を返します。
要素数が無限の場合は Float::INFINITY を返します。
Enumerator.new に Proc オブジェクトを指定していた場合はその
実行結果を返します。呼び出した時に要素数が不明であった場合は nil を返し
ます。
/....../emlist[例][ruby]{
(1..100).to_a.permutation(4).size # => 94109400
loop.size # => Float::INFINITY
(1..100).drop_while.size # => nil
//}
@see Enumerator.new... -
Enumerator
# each -> self (9019.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...戻り値をそのまま返します。
@param 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"......orld!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(: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... -
Enumerator
# each { . . . } -> object (9019.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...戻り値をそのまま返します。
@param 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"......orld!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(: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... -
Enumerator
# each(*args) { . . . } -> object (9019.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...戻り値をそのまま返します。
@param 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"......orld!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(: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... -
NEWS for Ruby 2
. 6 . 0 (6174.0) -
NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.6.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......numerable
* 新規メソッド
* Enumerable#chain はレシーバと引数のそれぞれの要素を順番にイテレートする
Enumerator::Chain オブジェクトを返します。 15144
* 変更されたメソッド
* Enumerable#to_h はブロックを受け取り......うになりました。 15143
* 別名
* Enumerable#filter が Enumerable#select の別名として追加されました。 13784
* Enumerator::ArithmeticSequence
* 等差数列(隣接する項が共通の差(公差)を持つ数列)のジェネレーターを表現する新しい... -
NEWS for Ruby 2
. 7 . 0 (6132.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.7.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......name: "Alice", children: [{name: "Charlie", age: age}]}
#=> NoMatchingPatternError
//}
* 詳細は https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7 のスライドを参照してください。
* スライドは少し古い内容になっていることに注意して......>1}
//}
* Enumerator
* 新規メソッド
* 任意のデータ変換からEnumeratorを作成するための
Enumerator.produceメソッドが追加されました。 14781
* lazy enumerator から lazy ではない enumerator を生成する
Enumerator::Lazy#eager... -
NEWS for Ruby 2
. 0 . 0 (6102.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.0.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......メソッドです
* Enumerator
* 追加: Enumerator#size サイズを遅延評価するためのメソッドです
* 拡張: Enumerator.new サイズの遅延評価のための引数を一つ受け取るようになりました
* 新規クラス: Enumerator::Lazy 遅延列挙用の......* 返り値変更:
* String#lines Enumerator ではなく Array を返します
* String#chars Enumerator ではなく Array を返します
* String#codepoints Enumerator ではなく Array を返します
* String#bytes Enumerator ではなく Array を返します
*... -
NEWS for Ruby 3
. 0 . 0 (6066.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 3.0.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......ray#slice!
* Array#slice / Array#[]
* Array#take
* Array#take_while
* Array#uniq
* Array#*
* Can be sliced with Enumerator::ArithmeticSequence
//emlist[][ruby]{
dirty_data = ['--', 'data1', '--', 'data2', '--', 'data3']
dirty_data[(1..).step(2)] # take each second......s: Read ENV names and values as UTF-8 encoded Strings 12650
* Encoding
* Added new encoding IBM720. 16233
* Changed default for Encoding.default_external to UTF-8 on Windows 16604
* Fiber
* Fiber.new(blocking: true/false) allows you to create non-blocking execution contexts. 16786... -
NEWS for Ruby 3
. 1 . 0 (6054.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 3.1.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......2, 3].each_cons(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]
[1, 2, 3].each_slice(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]
//}
* Enumerator::Lazy
* 新規メソッド
* Enumerator::Lazy#compact が追加されました。 17312
* File
* 変更されたメソッド
* File.dirname が......* Thread::Queue
* 変更されたメソッド
* Thread::Queue.new が、初期値のEnumerableオブジェクトを渡せるようになりました。 17327
* Time
* 変更されたメソッド
* Time.new は、Time.at や Time.now と同じようにタイムゾーンの in:...