I finally got around to listening to #225 and the for/foreach and
regex/string literal discussion was hilarious.

IMO for/foreach can be removed from the language in favor of
collection API methods like you guys said. But you need some kind of
lambda syntax. Scala does this already. for/foreach doesn't matter,
just pick the right method.

val list = List(1,2,3,4,5)

list.foreach(x => println(x))

if you want indexes, you can use zipWithIndex.

list.zipWithIndex.foreach { case(x,i)=> println(x,i) }

Java wouldn't necessarilly need the tuple support to make this work.
e.g. consider the lambda support in C#, assuming the same methods are
defined:

var list = new[] {1,2,3,4,5};
list.zipWithIndex.foreach( (x,i) => Console.WriteLine(x,i) );

So java just needs a nice anonymous method & lambda syntax to get to
the first-class function point that its collection libraries can
support.

Nice discussion guys,
--
Jay
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to