RE: The best way to toggle a boolean variable. 07-16-2018, 06:32 AM
#3
(07-16-2018, 06:00 AM)reGEN Wrote: Sure, but it's not very readable... It's something that works but probably shouldn't do... like I can do a basic addition of two numbers using XOR as well...
Code:int one = 1, two = 2;
int three = one ^ two;
but am I actually going to? And sure, you could argue that it's convenient for very long variable names but that seems like a totally contrived example because if you have super long variable names, you have another issue. But maybe it's just me. ¯\_(ツ)_/¯
Of course, it is ultimately a matter of programmer preference. It may not be readable to less-experienced Java programmers, but to well-experienced programmers, it would be very readable.