From: Michael Jackson Date: 2010-07-27T02:08:20+09:00 Subject: Re: stop program with entering a key... The following code doesn't do exactly what you need, but it should be enough to get you started in the right direction. def prompt STDOUT.write ">> " gets end def game_over puts "thank you.\ngame over!" exit end trap ("INT") { puts; game_over } puts "welcome to my game. please press 'q' to quit." while (code = prompt) case code.strip when "y" puts "start game" when "q" game_over else puts "sorry, i don't understand." end end -- Michael Jackson http://mjijackson.com @mjijackson On Mon, Jul 26, 2010 at 5:50 AM, hazal Ates wrote: > i m a new in Ruby . sorry may be its a silly question. > my small game " finding a randon number" in codes i want to put > "pls press -1 to stop game" > or > end of first game i want to ask > "do you cont. or  stop ( y / n ) enter , pls" > > but i dont know that how (-1) or y/n work to stop or cont. > > i want to like this code  : > if keyenter=(-1) goto last line and stop > if keyenter = y goto beginning of game > if keyenter = n goto end of prog. it says puts "thank you , game over" > like this... > -- > Posted via http://www.ruby-forum.com/. > >