IF ELSE VERSUS CASES FORMALISM

IF ELSE VERSUS CASES FORMALISM - CANNOT MAKE THESE EQUAL - Mensajes

#1 Publicado: 9/5/2024 2:35:48
RegRetired

RegRetired

8 me gusta en 144 mensajes.

Grupo: User

Help would be appreciated. I cannot make a chain of if-else statements equal to the cases formalism. What am I missing. I have tried the less than or equal only in the cases formalism. That didn't work either. The if-else results are correct, the cases formalism is not correct.

IF ELSE VERSUS CASES FORMALISM.sm (12,76 KiB) descargado 1654 vez(es).

Thanks for any help.
Reg
Reg CurryLoveland, CO
#2 Publicado: 9/5/2024 2:43:15
RegRetired

RegRetired

8 me gusta en 144 mensajes.

Grupo: User

Oops sorry. I had errors in my formulas. Here is the corrected version where the two formalisms do agree.

IF ELSE VERSUS CASES FORMALISM.sm (12,47 KiB) descargado 1624 vez(es).

Sorry
Reg CurryLoveland, CO
#3 Publicado: 9/5/2024 16:09:52
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: Moderator

No problem, when possible, better ask.

I would point out that currently you can avoid the nested if/else and convert it in if/else if/else (if you wish), simply adding more arguments. As side note if you delete an argument from the default if/else, you'll get an if without else.

IF ELSE VERSUS CASES FORMALISM(2).sm (16,67 KiB) descargado 1702 vez(es).


Also, since the topic is about if/else vs cases, I would like to highlight that cases has a different coding approach to evaluate in some situations where if/else is not allowed to; this feature comes at the cost that you shouldn't make assignments ( : ) inside its arguments, while in if/else you can safely build block of codes inside it using the line function (see here and here for examples).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Publicado: 10/5/2024 1:02:59
RegRetired

RegRetired

8 me gusta en 144 mensajes.

Grupo: User

Davide,
Thanks much. Very helpful as always.
Reg
Reg CurryLoveland, CO
  • Nuevos mensajes
  • Sin mensajes nuevos