You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Henning P. Schmiedehausen" <hp...@intermeta.de> on 2004/09/22 15:02:40 UTC
Re: cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration/beanutils
Emmanuel Bourg <sm...@lfjr.net> writes:
[...]
>> Not a real issue, though.
>It's a matter of taste I think, I find the while() syntax more readable,
>the for(Iterator) looks more like a l33t h4cK ;) Fortunately the new
>foreach syntax will settle this issue definitely.
The different visibility makes is impossible to "reuse" the iterator
after the loop. Creating "fun" things like is not that easy anymore...
--- cut ---
Iterator it = list.iterator();
while (it.hasNext() && someCondition)
{
String foo = (String) it.next();
[... do something ...]
}
if (!it.hasNext() && someOtherCondition)
{
it = anotherList.iterator();
}
while (it.hasNext())
{
String foo = (String) it.next();
[... do something ...]
}
--- cut ---
This is a fragment from actual code that I had to debug. I needed
almost a full bottle of red wine to survive it.. ;-)
Regards
Henning
(Regarding Java 1.5: Oh, that _will_ be fun. :-) )
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
Linux, Java, perl, Solaris -- Consulting, Training, Development
"Fighting for one's political stand is an honorable action, but re-
fusing to acknowledge that there might be weaknesses in one's
position - in order to identify them so that they can be remedied -
is a large enough problem with the Open Source movement that it
deserves to be on this list of the top five problems."
-- Michelle Levesque, "Fundamental Issues with
Open Source Software Development"
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org