LoginSignup
2
1

More than 5 years have passed since last update.

Rubyで外部ループを抜けたい

Last updated at Posted at 2013-06-04
catch (:done) do
  5.times { |i|
    5.times { |j|
      puts "#{i} #{j}"
      throw :done if i + j > 5
    }
  }
end

外部ループを抜けたいときはcatchとthrowを使えばよい

2
1
0

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
  3. You can use dark theme
What you can do with signing up
2
1