What if I have a data structure that is logically iterable yet not a Collection nor an array? How would I use for in say, a Vector or Matrix class of my own design? What if I wanted that for loop to iterate over the elements of a Matrix in some nonstandard denumerable manner?
It would seem more logical to me for Java to simply apply allow blocks as used in Smalltalk.
Collection c; ...
for (String s : c)
What if I have a data structure that is logically iterable yet not a Collection nor an array? How would I use for in say, a Vector or Matrix class of my own design? What if I wanted that for loop to iterate over the elements of a Matrix in some nonstandard denumerable manner?
It would seem more logical to me for Java to simply apply allow blocks as used in Smalltalk.
URL : Enhanced for discussion on JCP site
URL : About Smalltalk Blocks
By Yours Truly (Shameless Plug): (And GPL/Artistic'd to boot) http://freshmeat.net/projects/gjal/