+ 1
Почему в коде используются 2 амперсанта(&&), а не один?
2 ответов
+ 4
Здравствуйте, Olga !
when
condition1 && condition 2
The second condition is checked only if the first condition is satisfied
when
condition1 & condition2
The second condition will be checked regardless of the fulfillment of the first condition.
It should be noted that instead of a condition there can be an expression.
in other words, single & will compare obtained in conditions 1 and 2, and therefore both halves are needed, and double && simply checks the result of the logical expression and if the first (left) part has already given a LIE, then it does not make sense to continue...
+ 2
Спасибо большое, все встало на свои места 😊