while false
puts1
end
Even under these conditions, ruby does not have a while to run at least once.
ruby-on-rails ruby
You can combine the begin clause with the while qualifier.
begin
puts1
end while false
However, this notation is not recommended in the Ruby Style Guide. Use the loop/break
combination instead.
loop do
puts1
breakless false
end
The while qualifier behaves differently depending on whether or not it is combined with the begin clause, so it is a cause of misunderstanding.
puts1 while false# Do nothing
begin;puts1;end while false#puts1 is called
begin
puts1
end while false
How about
© 2024 OneMinuteCode. All rights reserved.