From: Christopher Dicely Date: 2011-05-08T07:53:28+09:00 Subject: Re: Help with while condition OR condition On Saturday, May 7, 2011, Bill W. wrote: > Hi everyone, > > This is my first post, so I hope I don't sound too inexperienced.. > > I'm trying to teach myself Ruby, and have run into an issue with a while > statement that will break if an input is "exit" or "quit". > As of right now, it works if exit is input, but not quit > > I know I am completely misusing the entire thing, but here is what I > came up with: > > EXIT = "exit"  #need constants since Ruby gets pissed at string literals > QUIT = "quit"  #in a comparison > > print "Input: " > input = gets > while input.chomp.downcase != (EXIT || QUIT) #only works for exit The || operator returns the operand on the left if it is "true-ish" (anything other than nil or false), otherwise it evaluates and returns the operand on the right. So (EXIT || QUIT) where EXIT="exit" just evaluates to "exit". You could do this with the || between two comparisons (rather than two options in one comparison). Also, Ruby has no problem with comparisons against string literals; what made you think it did?