From: corey konrad <0011@...> Date: 2006-05-16T09:46:12+09:00 Subject: Re: learn to program cant because live ruby irb closes completly when i enter that code. It doesnt work. jake m wrote: > corey konrad wrote: >> oh ok he is just talking about variable scope it was kind of hard to >> tell from his example for some resaon, i dont know i think i am going to >> skip this learn to program book, this chris guy really doesnt know how >> to explain things to a person with a beginner mind set. i also am having >> problems running his code examples i really dont understand how the >> code below works but when i copy and paste it into the live ruby program >> all it does is close the live ruby program and shuts it down. >> >> def ask question >> good_answer = false >> while (not good_answer) >> puts question >> reply = gets.chomp.downcase >> if (reply == ' yes' or reply == ' no' ) >> good_answer = true >> if reply == ' yes' >> answer = true >> else >> answer = false >> end >> else >> puts ' Please answer "yes" or "no".' >> end >> end >> answer # This is what we return (true or false). >> end > > Corey, that is the definition of a method. to get a result add something > like > response = ask 'are you wearing a blue shirt' > puts response -- Posted via http://www.ruby-forum.com/.