Here’s a line from a large Java program which compiles without errors. I’m unable to understand how the <= operator is being used on the right side of assignment statement:
converged = measure.distance(centroid.getLengthSquared(), centroid, getCenter()) <= convergenceDelta;
Is this some obscure Java feature?
No, it’s not.
As you will see
convergedwill be ofbooleantype.It will be exactly the same as saying
So, probably in your code
measure.distance(centroid.getLengthSquared(), centroid, getCenter())returns a number which is then compared using the relational<=operatorwith
convergenceDelta;. The result will betrueorfalse, a boolean value which willbe saved at
converged.