by QuantumLogic · 10y ago · 0 comments
let greater = a < b ? b : a;
Is a lot better than having to write this all the time: let greater = if a < b { return a; } else { return b; }; if a < b { b } else { a }
why are you adding sprurious returns? And if you need to get the minimum of two values so much that actually impacts you, write a `min!` macro? use std::cmp::min;
min(a, b);
https://doc.rust-lang.org/std/cmp/fn.min.htmlSince if is an expression, ternay operators would be wholly redundant.
What are you talking about? A ternary isn't a higher level of abstraction, it's at best the exact same thing with a different syntax, at worst it's a more limited version of the same.