Arne O. Ose :
Is there an easy way to compare several arguments to the same value? To exemplify what I mean I have written this code which doesn't work, but illustrates what I'm looking for:
if ((arg1 && arg2 && arg3) > 0)
Instead of needing to write:
if (arg1 > 0 && arg2 > 0 && arg3 > 0)
Benefits would, in my opinion, be easier to read the code, and only needing to change one value.
Mureinik :
One neat trick is to stream all the arguments and use allMatch
with the predicate you want to check:
if (IntStream.of(arg1, arg2m arg3).allMatch(x -> x > 0)) {