I have a dream....
In this dream I can replace such constructs as:
if(aLongVariableName.equals(classInstance.aPropertyOfThatInstance) ||
aLongVariableName.equals(classInstance.aDifferentProperty)){
...
}
with
if(aLongVariableName.equals(classInstance.aDifferentProperty || aPropertyOfThatInstance)){
...
}
I think the later is more succinct, and easier to read. I'm sure something should be possible as methods can be declared with this kind of signature public void readUnlimitedVariables(Variable ... vars)
which takes comma separated variables (as opposed to ||
or even &&
).
This could be opened up to anything that returns a boolean, for instance:
if(myLovelyInstance instanceof AwesomeClass && EpicClass){
...
}
where myLovelyInstance
implements AwesomeClass && EpicClass
Is this possible in Java? I've not found anything on this so far, by googling or on SO. If it's not in vanilla Java, are there any third party packages like Lombok or lambdaJ that would allow this? If not that either, if this a feature of any language? It seems very intuitive to me but I've not seen it anywhere.