How come this is not possible? I am getting illegal start of expression.
(s1.charAt(i) == ' ') ? i++ : break;
The thing to understand here is that the ?: operator is used to return a value. You're basically calling a function that looks like this in that line:
anonymous function:
if(s1.charAt(i) == ' '):
return i++;
else:
return break;
Makes no sense, right? The ?: operator was only designed as a shorthand for if/else return statements like the above, not a replacement of if/else altogether.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With