3 ms·
My Dream C++ Additions
- tcbawo 3y agoI always liked C#’s null coalescing operator ?? (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...). Rather than changing if/else fundamentally, I would prefer something along the lines of: “int x = expression1 unless (conditionY) expression2;”.
- mdwalters 3y agoJavaScript has something like that: let x = true ? "x" : "y"; // sets x to "x"
- tcbawo 3y agoC++ has ternary expressions as well. The author was proposing a change to if/else as a more readable alternative to the ternary symbols. IMO using something like: x = “x” unless(true) “y” Wouldn’t follow the usual left to right order of evaluation, but I think it’s a somewhat readable alternative.