From: Daniel Peikes Date: 2007-12-16T15:18:32+09:00 Subject: Re: How t owrite an OR statement Joseph Pecoraro wrote: >> while again != "y" || "n" > > > These don't use the OR logic, but they are similiar. > until again ~= /^[yn]/i do > ... > end > > Or if your wanted to keep the while keyword you could do this as: > while again[0] != /^[^yn]/i do > ... > end > > > I don't know if you can do exactly what you are trying to do with that > syntax. You can reconstruct the logic like this: > while again != "y" && again != "n" do > ... > end > > > Here is another approach more along the lines of what you have (is > something in a list of something else), likewise the until loop could be > made a while loop: > good_chars = %w(y n) #=> ['y', 'n'] > until good_chars.include? again do > ... > end This is what I currently have, but it looks to be giving me an infinite loop: again = "y" number = [] while again == "y" puts "Please enter a number." number = gets.chomp puts "Would you like to enter a number again? y/n" again = gets.chomp.downcase while again != "y" or "n" puts "Would you like to enter a number again? y/n" end end puts number hold = gets -- Posted via http://www.ruby-forum.com/.