Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Help with while condition OR condition
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Bill W., post: 4682792"] 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! [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Help with while condition OR condition
Top