IF ELSE VERSUS CASES FORMALISM

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

#1 Posted: 5/9/2024 2:35:48 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: 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 KiB) downloaded 29 time(s).

Thanks for any help.
Reg
Reg Curry Loveland, CO
#2 Posted: 5/9/2024 2:43:15 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: 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 KiB) downloaded 36 time(s).

Sorry
Reg Curry Loveland, CO
#3 Posted: 5/9/2024 4:09:52 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: 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 KiB) downloaded 61 time(s).


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 Posted: 5/10/2024 1:02:59 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

Davide,
Thanks much. Very helpful as always.
Reg
Reg Curry Loveland, CO
  • New Posts New Posts
  • No New Posts No New Posts