From: Thiago Massa Date: 2010-07-27T16:52:38+09:00 Subject: Re: stop program with entering a key... --00151743fa10d22a95048c59c8e6 Content-Type: text/plain; charset=ISO-8859-1 Just define a function like "play_game" and do a loop that gets the input in order to play the game or not and calls that function. I don't even know how to use goto's. 2010/7/26 hazal Ates > Michael Jackson wrote: > > 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 > > thank you MJ > > my desire generaaly not for func. of this but > > after press. "y" for example ( at the last line ) prog execution must > GOTO beginning of program . > > may be you now in pascal its easy with GOTO > > -- > Posted via http://www.ruby-forum.com/. > > -- Thiago Fernandes Massa 11 83979414 --00151743fa10d22a95048c59c8e6--