Switchif() vs If()

Hello!

I use if() statements a lot. But I often find myself going back and changing it to a switchif() as the project grows. Is there any reason I shouldn’t always use a switchif() from the start?

1 Like

i see no technical reason for avoiding the switchif() function

i habitually use switchif() in my projects because its much better, for the following reasons

  • it does not require the else clause, which is useful for simple cases
  • it allows many else-if clauses which are useful for complex logic
  • it matches the if statements of programming languages i am familiar with

but i do find that many coda makers find it slightly odd. they are more familiar with the if().

i guess it is a matter of personal preference.

to help others follow the logic, i often separate the different clauses with commented keywords
/*then*/ ... /*else-if*/ ... /*else*/ ... /*end-if*/
as otherwise we only have commas between the clauses and its hard to follow

max

8 Likes

:wave: @Samuel_Langford

Team SwitchIf() !!!
i found calculations are faster with SwitchIfs then IFs…
but maybe its a product of my imagination :yum:

Cheers!
Mel

1 Like