るりまサーチ

最速Rubyリファレンスマニュアル検索!
36件ヒット [1-36件を表示] (0.058秒)
トップページ > クエリ:Ruby[x] > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:-[x] > クエリ:puts[x] > クラス:Enumerator[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

Enumerator#next -> object (168.0)

「次」のオブジェクトを返します。

...
@see Enumerator#rewind

//emlist[例1][ruby]{
str = "xyz"
enum = str.each_byte

str.bytesize.times do
puts
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...
...# 121
# 122
# iteration reached at end
puts
enum.next
#=> 再度 StopIteration 例外が発生
//}

//emlist[例3: Kernel.#loop は StopIteration を捕捉します。][ruby]{
str = "xyz"
enum = str.each_byte
loop do
puts
enum.next
end
# => 120
# 121
# 122
/...

Enumerator#with_object(obj) -> Enumerator (120.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("foo")
to_three_with_string.each do |x,string|
puts
"#{string}: #{x}...

Enumerator#with_object(obj) {|(*args), memo_obj| ... } -> object (120.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("foo")
to_three_with_string.each do |x,string|
puts
"#{string}: #{x}...