You basically just replaced condition ? if_true : if_false with condition && if_true || if_false - that means that a falsy if_true will fall through to if_false.
condition ? if_true : if_false
condition && if_true || if_false
I don't really see the advantage of that solution.
No, because I'm not allowing "falsey" conditions, which I consider a failure in a language. false is a distinct value from an unset optional, and true is not the same as an optional with a value.
Having hard optional semantics allows this to work. Using truthy and falsey evaluations this fails.
A condition can obviously be false, but I guess that's not what you meant. For the sake of this argument, let's assume that condition c is true, value x is false and y is 1; in most languages, c ? x : y would result in false, whereas c && x || y would result in 1.
c ? x : y
c && x || y
If I understood you correctly, c ? false | 1 in leaf would too result in 1, thus breaking the original logic of a ternary operator.
c ? false | 1
No, c ? false | 1 would evaluate to false in Leaf. The | operator applies only to optional types, not truthy values.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.