search
LoginSignup
10

More than 5 years have passed since last update.

posted at

多重ループから抜ける

breakは、現在のblockを抜けるだけ。
多重ループを抜けるには、下記。

escape.rb
isBreak = false
10.times do |i|
  10.times do |j|
    if hoge()
      isBreak = true
      break
    end
  end
  break if isBreak
end

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
10