Women in Technology

Hear us Roar



Article:
  Readable Java 1.5
Subject:   c.size() == d.size() == e.size()
Date:   2003-10-22 14:01:14
From:   anonymous2
I'm having a little trouble with the use of c.size() == d.size() == e.size() in one of the author's examples:


void cancelAll(Collection c, d, e) {
assert c.size() == d.size() == e.size();
while ((Object o = eachof c) != null)
{
((TimerTask)o).cancel();
((TimerTask) eachof d).cancel();
((TimerTask) eachof e).cancel();
}
}


As far as I can tell, that use of == for three separate values is not permitted in Java. The way it works, as I understand it, is that either "c.size() == d.size()" or "d.size() == e.size()" (I don't remember the order of operations offhand) would evaluate to a boolean value. That leaves a comparison between a boolean value and an int, which is invalid.


Am I just missing something? I'm fairly knew to Java, but I tried to compile a small test program to see if foo == bar == baz was accepted, and it seems not to be.