2008-08-02から1日間の記事一覧
イテレート中に redo すると、現在のブロックを再実行します。 def foo puts "start.." 3.times {|i| puts "each.. #{i}" yield i } puts "end.." end # redo count = 0 foo {|i| puts "yield.. #{i}" redo if i == 1 && (count+=1) < 3 } 実行結果です。 st…
イテレート中に redo すると、現在のブロックを再実行します。 def foo puts "start.." 3.times {|i| puts "each.. #{i}" yield i } puts "end.." end # redo count = 0 foo {|i| puts "yield.. #{i}" redo if i == 1 && (count+=1) < 3 } 実行結果です。 st…