Is it possible to use a shorthand for ternary assignment expressions of the type
boolean x = false;
// ... code ...
a = x ? b : a; // Assigning a to a is pointless
a += x ? 1 : 0; // Adding 0 to a is pointless
I'm thinking something along the lines of
a = x ? b; // Assign b to a if x is true
a += x ? 1; // Add 1 to a if x is true
Not that it saves a lot of typing, I'm just curious if something like this exists. I just recently discovered the null coalesce operator in PHP 7, which does something kind of similar. To me it looks much cleaner than
if( x ) a = b;
if( x ) a += 1;
since these are assignments, and using a ternary expression looks more natural when reading from left to right. The supposed duplicate question isn't about assignments specifically, which in my opinion are a special use case of the ternary operator.