while -- end は「する限りは」という場合だが、「そうでない限りは」 というときには、until -- end を使う。until.rb:
#!/usr/koeki/bin/ruby ans = "stop" until false STDERR.print("誰か止めて!!: ") guess = gets.chomp! if guess == ans break end end print("止まった!\n")
==
\n