|
|
|
|
|
by microtonal
4671 days ago
|
|
They are unnecessary in all other cases. For example, for your (key, value) example: But the Java 'foreach' loop is just syntactic sugar around iterators, and your fragment will expand to: for (Iterator<Entry<String, String>> iter = map.entrySet().iterator(); iter.hasNext(); ) {
Entry<String, String> entry = iter.next();
...
}
For this reason, the foreach-loop requires that the object that you loop over implements the Iterable interface. |
|
To be honest, every release of Go feels more and more like Java anyway. I won't be surprised when Go eventually ends up being a JVM-less Java in the same way a new OS will end up being unix. After all, "Those who don't understand Unix are condemned to reinvent it, poorly." – Henry Spencer
Maybe Java is the same way? Not to say unix (plan 9?) or java (scala?) are perfect, but there is a reason they are popular.