# Expression Switch-Case Fall-Through

**URL:** <https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [April 14, 2022, 2:34pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471 "2022-04-14T14:34:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 14, 2022, 2:34pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/1 "2022-04-14T14:34:32Z")

</div>

Using the expression switch function, is there any way to declare a fall-through for cases like with C:

```auto
switch(x){
   case a:
   case b:
   case c:
         printf("Cases a, b, & c);
   case d:
         printf("Case d");
}

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 14, 2022, 2:38pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/2 "2022-04-14T14:38:12Z")

</div>

You mean an expression for a binding? Here’s a way you do a switch statement

```auto
switch (
15 , // value
1 , // case 1
24 , // case 2
15 , // case 3
44 , // return 1
45 , // return 2
46 , // return 3
- 1 ) // default

```

[https://docs.inductiveautomation.com/display/DOC80/switch](https://docs.inductiveautomation.com/display/DOC80/switch)

Though normally instead of hardcoding a value like `15` that is where you’d have some other property.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 14, 2022, 2:39pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/3 "2022-04-14T14:39:09Z")

</div>

Yes, but am I able to do a fall-through like the C code I posed with a single return for cases 1-3?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 14, 2022, 2:39pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/4 "2022-04-14T14:39:20Z")

</div>

No.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 14, 2022, 2:40pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/5 "2022-04-14T14:40:35Z")

</div>

You’re best off making a separate property that checks `a || b || c` and then having that as one of the switch cases.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 14, 2022, 2:41pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/6 "2022-04-14T14:41:06Z")

</div>

Figured that was the case.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 14, 2022, 2:46pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/7 "2022-04-14T14:46:33Z")

</div>

Note that the expression language doesn’t short-circuit sub-expression evaluation. Nor does it fold common sub-expressions. Anywhere those matter, the sub-expressions should be moved to separate bindings/expression tags.

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://forum.inductiveautomation.com/u/peter)\
**Post date:** [April 14, 2022, 2:48pm UTC](https://forum.inductiveautomation.com/t/expression-switch-case-fall-through/58471/8 "2022-04-14T14:48:41Z")

</div>

As an aside I was confused, because your initial post mentions “C” (which only later you confirm as the language), and your example code shows “case c” 🤪

(and because there is no “break” statement, technically everything falls through to “d” anyway)
