IF ELSE VERSUS CASES FORMALISM

IF ELSE VERSUS CASES FORMALISM - CANNOT MAKE THESE EQUAL - Сообщения

#1 Опубликовано: 09.05.2024 02:35:48
RegRetired

RegRetired

8 сообщений из 130 понравились пользователям.

Группа: 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 КиБ) скачан 31 раз(а).

Thanks for any help.
Reg
Reg Curry Loveland, CO
#2 Опубликовано: 09.05.2024 02:43:15
RegRetired

RegRetired

8 сообщений из 130 понравились пользователям.

Группа: 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 КиБ) скачан 38 раз(а).

Sorry
Reg Curry Loveland, CO
#3 Опубликовано: 09.05.2024 16:09:52
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: 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 КиБ) скачан 62 раз(а).


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 Опубликовано: 10.05.2024 01:02:59
RegRetired

RegRetired

8 сообщений из 130 понравились пользователям.

Группа: User

Davide,
Thanks much. Very helpful as always.
Reg
Reg Curry Loveland, CO
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений