From: sto.mar@... Date: 2013-06-21T03:31:17+09:00 Subject: Re: Long conditionals/ multiple conditionals Am 20.06.2013 08:38, schrieb Joel Pearson: > Your problem is that this is always true: > if reply == "no".to_s or "hell no".to_s or "nah".to_s > > That is: > if reply == "no".to_s # This is a true/false result > or "hell no".to_s # This will always return true, because "hell no" is > true. > You're missing the comparison there. > > You wanted: > if reply == "no" or reply == "hell no" or reply == "nah" > > > The "to_s" is unnecessary, console input is already a string. more relevant here: string literals like "no", "nah", ... are already strings! :) > With your current code, "No" is treated differently from "no". You could > try gets.chomp.downcase to make all input lowercase. > > It's the accepted practice in Ruby to use && || rather than "and" "or". "and", "or" have their use cases (control flow), but indeed, for boolean expressions you should definitely use &&, ||. (It will save you debugging time.) > In this particular instance I'd probably use a "case" statement with > Regular Expressions to try and extract the content. --