Having trouble with using ternary operator.
...
char symbol = str_base[i];
int count = 1;
...
(count == 1) ? str_rle += symbol : str_rle += count.ToString() + symbol;
Getting such error:
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Why? Does ternary operator really only with: calling functions, ++ & — ?
Thank you!
The left hand side of your line is a comparison not an assignment (not sure what you are trying to do here). I wish you could use ternary operators for this kind of conditional execution but unfortunately you can’t. You can use the ternary operator in this case on the other side of the expression though;