Another form you can use is with begin/end : while « Statement « Ruby






Another form you can use is with begin/end


temp = 98.3

begin
  print "Your temperature is " + temp.to_s + " Fahrenheit. "
  puts "I think you're okay."
  temp += 0.1
end while temp < 98.6

puts "Your temperature is " + temp.to_s + " Fahrenheit. Are you okay?"

 








Related examples in the same category

1.Here's the formal specification for the while loop:
2.The while Loop
3.The while loop executes its contained code while a condition that you specify remains true.
4.While loop with array length
5.loop code based on the result of a comparison made on each loop
6.use while loop to convert elements in an array to capitalized case
7.Replace one array with another