We have n variables X = {x1,x2,...xn} they are not in any structures whatsoever.
In python for example I can do that: if (x1 == x2 == x3 == xn):
In java I must do: if((x1 == x2) && (x2 == x3) && (x3 == xn)):
Do you know a simple way to improve this syntax? (Imagine very long variable name and lot of them)
Thanks.
If you have lots of these variables, have you considered putting them in a collection instead of having them as separate variables? There are various options at that point.
If you find yourself doing this a lot, you might want to write helper methods, possibly using varargs syntax. For example:
An alternative as presented by glowcoder is to force there to be at least one value:
In either case, use with: