Comment Comment by pistoleer After some thinking, the ternary conditional operator can be decomposed into 2 composing binary operators like such:? takes a bool, a T, and returns option<T>true?b == Result bfalse?b == None: takes an Option<T> and a T and returns TResult x : y == xNone : y == yHowever, in most languages (looking at you php) the ?: act as a type of parenthesis: in a?b:c, any expression goes into b, no matter it's precedence. parent pistoleer 2 years ago
? takes a bool, a T, and returns option<T>
true?b == Result b
false?b == None
: takes an Option<T> and a T and returns T
Result x : y == x
None : y == y
However, in most languages (looking at you php) the ?: act as a type of parenthesis: in a?b:c, any expression goes into b, no matter it's precedence.