The 'break value' statement is another option:

result = while true do
  print "Enter a number: "
  input = gets.chomp
  if input == "quit"
    exit
  elsif input.to_i.to_s == input
    break input.to_i
  end
end

puts "You entered #{result}"

Calling "break" with a value makes that value the return value of the loop,
which is what you want here.

martin
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>