# Long conditionals/ multiple conditionals

**URL:** <https://rubytalk.org/t/long-conditionals-multiple-conditionals/68050>\
**Category:** ruby-talk\
**Created:** [20 June 2013 04:55 UTC](https://rubytalk.org/t/long-conditionals-multiple-conditionals/68050 "2013-06-20T04:55:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [20 June 2013 04:55 UTC](https://rubytalk.org/t/long-conditionals-multiple-conditionals/68050/1 "2013-06-20T04:55:33Z")

</div>

Hi everyone! I am new to Ruby so I need help. Much appreciated!

My problem is this code right here:

puts "Heeeyyyy! I see you baby, can a G get to know yah?"

reply = gets.chomp

if reply == "no".to\_s or "hell no".to\_s or "nah".to\_s  
puts 'Why do you have to be so jacked up, I just want to get to know  
you, that\'s all?'

elsif reply == "yes"&& "sure"&& "maybe"  
puts 'hmmm I see you recognize a real man when you see one.'

else  
puts 'Okay okay we got of on the wrong foot, I will be respectful...I am  
going to try this again.'

end

My questions is, when having two multiple conditions do I use && or ||  
or .to\_s between the words? With my current method, what ever I type, I  
get the response from the second puts.("Jacked up"). I want to be able  
to type any of the options and get the proper response. Anyone please  
help me how to craft multiple conditionals. Thank you 🙂

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [20 June 2013 06:38 UTC](https://rubytalk.org/t/long-conditionals-multiple-conditionals/68050/2 "2013-06-20T06:38:10Z")

</div>

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.

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".

In this particular instance I'd probably use a "case" statement with  
Regular Expressions to try and extract the content.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [21 June 2013 03:56 UTC](https://rubytalk.org/t/long-conditionals-multiple-conditionals/68050/3 "2013-06-21T03:56:14Z")

</div>

Thank you!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![stomar](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@stomar](https://rubytalk.org/u/stomar)\
**Post date:** [20 June 2013 18:31 UTC](https://rubytalk.org/t/long-conditionals-multiple-conditionals/68050/4 "2013-06-20T18:31:17Z")

</div>

> 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.)

> **···**
>
> Am 20.06.2013 08:38, schrieb Joel Pearson:
> 
> > In this particular instance I'd probably use a "case" statement with  
> > Regular Expressions to try and extract the content.
> 
> --  
> \<[https://github.com/stomar/&gt](https://github.com/stomar/&gt);

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [21 June 2013 03:44 UTC](https://rubytalk.org/t/long-conditionals-multiple-conditionals/68050/5 "2013-06-21T03:44:19Z")

</div>

Thank you very much !!!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
