別のキーワード
種類
- インスタンスメソッド (71)
- 文書 (5)
ライブラリ
- ビルトイン (71)
クラス
- Enumerator (22)
-
Enumerator
:: Lazy (10)
モジュール
- Enumerable (39)
キーワード
-
NEWS for Ruby 2
. 7 . 0 (5) -
each
_ with _ index (22) -
to
_ h (17)
検索結果
先頭5件
- Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object - Enumerator
:: Lazy # with _ index(offset = 0) {|(*args) , idx| . . . } -> Enumerator :: Lazy - Enumerator
# with _ index(offset = 0) -> Enumerator - Enumerator
:: Lazy # with _ index(offset = 0) -> Enumerator :: Lazy - Enumerable
# each _ with _ index(*args) -> Enumerator
-
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (18227.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
..."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|", 1]
# ["bar|", 2]......にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。... -
Enumerator
:: Lazy # with _ index(offset = 0) {|(*args) , idx| . . . } -> Enumerator :: Lazy (18215.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...クスは offset から始まります。
ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。
//emlist[][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}
@see Enumerator#with_index... -
Enumerator
# with _ index(offset = 0) -> Enumerator (18127.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
..."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|", 1]
# ["bar|", 2]......にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。... -
Enumerator
:: Lazy # with _ index(offset = 0) -> Enumerator :: Lazy (18115.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...クスは offset から始まります。
ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。
//emlist[][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}
@see Enumerator#with_index... -
Enumerable
# each _ with _ index(*args) -> Enumerator (6240.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...返すような
Enumerator を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡......each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}
@see Enumerator#with_index... -
Enumerable
# each _ with _ index(*args) {|item , index| . . . } -> self (6240.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...返すような
Enumerator を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡......each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}
@see Enumerator#with_index... -
Enumerable
# to _ h(*args) -> Hash (114.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...ue] のペアの配列として解析した結果を Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}
ブロックを指定すると各要素でブ... -
Enumerable
# to _ h(*args) { . . . } -> Hash (114.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...ue] のペアの配列として解析した結果を Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}
ブロックを指定すると各要素でブ... -
Enumerable
# to _ h(*args) -> Hash (113.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...self を [key, value] のペアの配列として解析した結果を Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}... -
NEWS for Ruby 2
. 7 . 0 (30.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ドのブロック引数として渡せるようになりました。 15618
* Enumerator::Lazy#with_indexメソッドが追加され、
以前のlazyではないEnumerator#with_indexのデフォルト実装から
lazyになりました。7877
//emlist[Enumerator.produce][ruby]{
requi......ger
p e.class #=> Enumerator
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
//}
//emlist[Enumerator::Lazy#with_index][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}
* Fiber
* 新規メソッド......* rb_scan_argsの書式文字列の「:」はキーワード引数として扱われるようになりました。
キーワード引数の代わりに位置引数のハッシュとして渡されるとdeprecated警告が
出ます。
* ANYARGSを使ったC API宣言はANYARGSを使わ...