# Switch statement

**URL:** <https://forums.eggplantsoftware.com/t/switch-statement/2518>\
**Category:** Eggplant Functional\
**Created:** [December 9, 2009, 3:16pm UTC](https://forums.eggplantsoftware.com/t/switch-statement/2518 "2009-12-09T15:16:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roundhillmark](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/r/4da419/32.png) [@roundhillmark](https://forums.eggplantsoftware.com/u/roundhillmark)\
**Post date:** [December 9, 2009, 3:16pm UTC](https://forums.eggplantsoftware.com/t/switch-statement/2518/1 "2009-12-09T15:16:30Z")

</div>

Is there a switch statement in eggPlant or something equivilent?

ex.  
// x = state of a test; 0 = test failed, 1 = test passed,  
switch x {  
case 0:  
put “Test failed”  
break  
case 1:  
put “Test passed”  
break  
default:  
put “Test not run!”  
break  
}

---

<div class="post-metadata">

**Author:** ![FHQWHGADS](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/f/c5a1d2/32.png) [@FHQWHGADS](https://forums.eggplantsoftware.com/u/FHQWHGADS)\
**Post date:** [December 9, 2009, 4:38pm UTC](https://forums.eggplantsoftware.com/t/switch-statement/2518/2 "2009-12-09T16:38:23Z")

</div>

Hello, RoundhillMark–

There is no switch/case structure currently available in SenseTalk. You would have to accomplish it with if/else if/else.

```auto
if x is equal to 0
  put "passed"
else if x is equal to 1
  put "failed"
else
  put "test not run"
end if

```

I will pass that request along to the developers. Thanks!

---

<div class="post-metadata">

**Author:** ![DaveHester](https://forums.eggplantsoftware.com/user_avatar/forums.eggplantsoftware.com/davehester/32/104_2.png) [@DaveHester](https://forums.eggplantsoftware.com/u/DaveHester)\
**Post date:** [October 13, 2017, 12:42pm UTC](https://forums.eggplantsoftware.com/t/switch-statement/2518/3 "2017-10-13T12:42:04Z")

</div>

In the eight years since this was first posted, is there yet a more elegant solution than a long string of if…then…else statements. I have a switch with nearly a dozen cases that I have to evaluate.

Thanks!

---

<div class="post-metadata">

**Author:** ![eggplanter](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@eggplanter](https://forums.eggplantsoftware.com/u/eggplanter)\
**Post date:** [March 1, 2026, 6:47pm UTC](https://forums.eggplantsoftware.com/t/switch-statement/2518/4 "2026-03-01T18:47:29Z")

</div>

There are Multi-Case If statements now, for anyone else Googling this and ending up here in 2026+ like I did.

```auto
if monthNumber is ... -- multi-case if statement
  1 : set monthName to "January"
  2 : set monthName to "February"
  -- 
  12: set monthName to "December"
  else: throw "Broken Calendar!"
end if

```
