A DESCRIPTION OF THE REQUEST :
The new "foreach" loop works with arrays and Iterable, but these two are treated differently and it is not possible to write a function that accepts both an array and an iterable (as does the "foreach" loop).
JUSTIFICATION :
It is cleaner and more flexible to handle iteration over arrays in exactly the same way as iteration over collections.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect that this function accepts Iterable<Byte>, Byte[] and, with the help of autoboxing, also byte[]:
void dumpBytes(Iterable<Byte> bytes) {
for( Byte b : bytes) {
}
}
If arrays would implement Iterable this could work.
CUSTOMER SUBMITTED WORKAROUND :
Currently you have to write 3 functions with different signature but identical implementation:
void dumpBytes(Iterable<Byte> bytes) {
for( Byte b : bytes) {
}
}
void dumpBytes(Byte[] bytes) {
for( Byte b : bytes) {
}
}
void dumpBytes(byte[] bytes) {
for( Byte b : bytes) {
}
}
###@###.### 10/11/04 05:00 GMT