From: Sam Rose Date: 2011-11-09T23:09:17+09:00 Subject: Re: Can't get "or" or "||" to work. Also, you will want to change || to &&. As it stands, you're checking that name is either not equal to "bob" or not equal to "fred". Whatever you put in there, it's going to be not equal to one of them :) Logic is tough to grasp at first but stick at it. It'll become clear if you practice! On 9 November 2011 14:06, Sam Rose wrote: > Hi James, > > You're very close. This code should work: > > name = gets.chop.downcase > if name != "bob" || name != "fred" >  puts "That wasn\'t one of the choices." > else >  code > > You have to have a full expression for each part of the conditional. > What was happening previously was this: > > The if statement checked the expression: name != bob > Then the is statement checked the expression: "fred" > > In Ruby, anything that is not nil or false is considered true. Thus > "fred" is considered true. > > I hope this has explained your problem :) > > Thanks, > Sam > > On 9 November 2011 14:02, james gallagher wrote: >> Hi.  I have a stupid question. >> >> I'm stuck on the bit of ruby that follows: >> >> name = gets.chop.downcase >> if name != "bob" || "fred" >>  puts "That wasn\'t one of the choices." >> else >>  code >> >> If I put "bob" in it says: >> >> That wasn't one of the choices. >> >> It does the same for anything I put in. >> >> Thank you. >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >