From: Hank Gong Date: 2006-06-22T18:53:13+09:00 Subject: Re: Newbie Questions ------=_Part_2635_11272440.1150969990659 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline p "Please input your choice:" menuinput=gets if menuinput.chomp! =="1" p "1" else p "other" end 2006/6/22, Paul Teale : > > Hi, > I am new to Ruby and have a newbie Ruby question that i couldn't find > the answer to in the FAQ. > If this is the wrong forum to post newbie questions please accept my > apologies and direct me to a more suitable forum where i can ask newbie > Ruby questions. Thanks. > > First i display a console based menu with puts statements and then wait > for input with the gets method like this.. > > menuChoiceString = gets > > Then i have the following code to act based on what menu option was > chosen. > > if menuChoiceString == "1" then > puts "You pressed 1" > else > puts "You pressed 2" > end > > When i use this and enter 1 it goes to the second option. > It looks fairly simple syntax so i'm not sure why the if statement is > failing. > Can anyone help me understand why this would fail? > > thanks > > Paul > > -- > Posted via http://www.ruby-forum.com/. > > -- Huazhi Gong (Hank) ------=_Part_2635_11272440.1150969990659--