From: Hashmal Date: 2011-05-08T08:11:08+09:00 Subject: Re: Help with while condition OR condition `(EXIT || QUIT)` will always return "exit" as EXIT is never `nil` or `false`, so in your case, the input string is never checked against `QUIT`. Try this: print "Input: " input = gets until ["exit", "quit"].include? input.chomp.downcase # Do something print "Input: " input = gets end As you can see you can do it without constants. the method `include?` checks if an element exists in the array. `until` is basically an inverted `while`. On 5/8/11 12:37 AM, 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 > > #Do something > > print "Input: " #pick up the next input and check it > input = gets > end > > I know that Ruby has a lot of shortcuts, but if you post any please > explain how they work (or provide a link to a good explanation. > > Thanks! >