M
markspace
Just thinking out loud here, mostly. I seem to write a lot of the
following type of loop:
Object[] array ....
for( int i = 0; i < array.length; i++ ) {
....
}
That is, a sequence of numbers less than some bound, starting at zero.
Wouldn't a compact form of this be handy?
Object[] array ....
for( int i : array.length ) {
....
}
The difference between this and the regular for-each is that the
identifier after the colon isn't an object (not an Iterable or an array)
but an integer primitive. It should work even with literals:
for( int i : 42 ) {
.... // i == 0..41 inclusive
}
With Java 7 coming up, is this JSR worthy?
following type of loop:
Object[] array ....
for( int i = 0; i < array.length; i++ ) {
....
}
That is, a sequence of numbers less than some bound, starting at zero.
Wouldn't a compact form of this be handy?
Object[] array ....
for( int i : array.length ) {
....
}
The difference between this and the regular for-each is that the
identifier after the colon isn't an object (not an Iterable or an array)
but an integer primitive. It should work even with literals:
for( int i : 42 ) {
.... // i == 0..41 inclusive
}
With Java 7 coming up, is this JSR worthy?