<p>You can put all of the logic outside of the switch block and use the "Logic" input of the switch block. You can do exactly what you have described in pseudo code since there are "less than"/"greater than" blocks and an "and" block.</p>

<p><a href="https://i.sstatic.net/TE7Re.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TE7Re.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2017-11-15T17:56:37.893Z
2017-11-15T17:56:37.893Z
David Lechner
<p>I can't find a way to emulate an AND statement in a switch statement:</p>

<pre><code>if (angle &gt;= 10 and angle &lt;= 30)
   ;// do smth
else
   ; // this is what I want
</code></pre>

<p>Until now, I just nested two if statements, but now I want to introduce an else case, but I don't want to duplicate the statements in the else condition two times (one in the first if, the second one in the nested one).</p>

<p>Is there a better way?</p>

CC BY-SA 3.0
2017-11-15T10:16:03.797Z
Hi SchoolGuy and welcome to Bricks! Which language are you using to program your EV3? (Hopefully you can edit your question to include that).
Zhaph - Ben Duguid
<ev3><software>
How do I have an else in conjunction with an if statement with two conditions?
SchoolGuy
# How do I have an else in conjunction with an if statement with two conditions?

(Asked by: username_0 on 2017-11-15)

I can't find a way to emulate an AND statement in a switch statement:
if (angle >= 10 and angle <= 30)
   ;// do smth
else
   ; // this is what I want

Until now, I just nested two if statements, but now I want to introduce an else case, but I don't want to duplicate the statements in the else condition two times (one in the first if, the second one in the nested one).
Is there a better way?

**Tags:** ev3, software

> **Comments:**
> **username_1**: Hi username_0 and welcome to Bricks! Which language are you using to program your EV3? (Hopefully you can edit your question to include that).  

---

## 1 answers

### Answer by username_2 on 2017-11-15. Score: 2

You can put all of the logic outside of the switch block and use the "Logic" input of the switch block. You can do exactly what you have described in pseudo code since there are "less than"/"greater than" blocks and an "and" block.

[![enter image description here](https://i.sstatic.net/TE7Re.png)](https://i.sstatic.net/TE7Re.png)


---

