[–] maguirre 11y ago ↗ There’s no ternary operators, but instead everything is an expression, so you just put an if statement in the middle of your expression like : a = if b > 1 { 1 } else { 2 }.I don't understand this takeaway. Did the author forget a word? [–] readams 11y ago ↗ a = if b > 1 { 1 } else { 2 }is equivalent to:a = b > 1 ? 1 : 2in other languages. Meaning that the if/else statement can be used as an expression that can provide an rvalue of integer type. [–] saurik 11y ago ↗ I think "but" is just incorrect to include: "; instead,". And "there's" should be "there are".
[–] readams 11y ago ↗ a = if b > 1 { 1 } else { 2 }is equivalent to:a = b > 1 ? 1 : 2in other languages. Meaning that the if/else statement can be used as an expression that can provide an rvalue of integer type.
[–] saurik 11y ago ↗ I think "but" is just incorrect to include: "; instead,". And "there's" should be "there are".
3 comments
[ 3.7 ms ] story [ 18.2 ms ] threadI don't understand this takeaway. Did the author forget a word?
is equivalent to:
a = b > 1 ? 1 : 2
in other languages. Meaning that the if/else statement can be used as an expression that can provide an rvalue of integer type.