3 ms·
> While it's not a boolean expression per Java, at least in my mind it serves the same purpose But if some construct looks the same, but is not the same, and w
by anyfoo 4y ago
> While it's not a boolean expression per Java, at least in my mind it serves the same purpose
But if some construct looks the same, but is not the same, and worse, only "somewhat" the same, you get confusing behavior. At least for newcomers, or even just software engineers who just don't care about language grammar that deeply (which I imagine are not only a lot, but also a lot of the Java target audience specifically).
Case in point, the author I was replying to wondered in a followup whether && would/should still act like a shortcut-and operator would, or not.
There is definitely some subjectivity to it, but personally I much prefer if different constructs look clearly different. Any ambiguity is squashed immediately, and in the case of "when" it's still fully clear how it works. I'm also okay with the "if" variant, because while it reuses a keyword, it's clearly a different "if".