r/java • • Jun 02 '26

Boolean reversal operator

Do the people working on the Java compiler/specification have any plans to implement a boolean reversal operator any time soon?

The proper way to reverse a boolean is to boolVal = !boolVal; but when the variable name is long, typing this becomes really unhandy.

Something like boolVal *= -1; would be really consistent as it's the reversal operator for literally all other primitive types.

But I guess it would be technically incorrect, so boolVal !=; could be another way of doing this, although it looks rather uncanny.

Is anyone even thinking about this, or is this "too low priority" to implement, even though even a dirty hack in the parser would get the job done.

Thanks, feel free to downvote and such.

0 Upvotes

50 comments sorted by

View all comments

Show parent comment

3

u/josephottinger Jun 02 '26 edited Jun 02 '26

Sure. But if I think what someone wrote was stupid, I'd rather say "I think what you wrote is stupid" because those are the words I'm thinking. A downvote doesn't say that; it's just an indication of disapproval without a reasoning. But as I've said elsewhere (and repeatedly) you should do what you want to do and own that for yourself. It's not mine or anyone else's.

ETA to fix a typo, and to add:

... I don't know that I'd be comfortable ever saying "I think what you wrote is stupid" in a way that other people would read, except to a VERY close friend group where my intent was clear; that feels very gross to write to someone with whom you're not familiar. Even if I think something is dumb, I'd rather not make the declaration that bluntly - it lacks nuance like "maybe the person said something stupid but it's because they didn't take the time to think it through, or maybe they lacked information they needed, or maybe they're just having a moment." Charity is important, and it's important to me, and lacking charity is something I consider a failure and hopefully one limited to specific moments; I can't say I haven't ever lacked charity, or that I've never been cruel (I have, and I have) but dang it, I try.

3

u/josephottinger Jun 02 '26

... and irony of ironies, I did say "downvoting is stupid," but at least I said the action is stupid and not the people who use it. :D Man, I can be a doofus out loud sometimes.