Yes/No. You're still forced to only use it with things that can be Iterables, yet there's a whole category of stuff where foreach makes sense, but can't be represented in this manner.
One of the more obvious examples here is something like a stream of lines coming over a network socket, in which you want the body of the foreach expression to be executed asynchronously for each incoming line (perhaps by dispatching to a thread pool), and for the expression as a whole to be non-blocking. On 31 July 2012 08:15, Roland Tepp <luol...@gmail.com> wrote: > Sorry, couldn't resist, but let your class implement Iterable and voila - > the foreach is extended! > > esmaspäev, 30. juuli 2012 15:55.30 UTC+3 kirjutas Ricky Clarkson: > >> 6. foreach is not open for extension, i.e., it only works with Iterables >> and arrays. >> > -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To post to this group, send email to javaposse@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.