Interesting article showing some changes on the Java platform to address its verbosity, but keeping code readability safe.
I liked the new Collection’s literals syntax to create lists, sets and maps:
ListpowersOf2 = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
Mapages = {"John" : 35, "Mary" : 28, "Steve" : 42};
Although it can be possible to use the DoubleBraceInitialization idiom to initialize collections in a more elegant way, this syntax is very terse and concise.
BTW, as I said before, Scala already has a syntactic sugar to create a literal Map:
val ages = Map("John" -> 35, "Mary" -> 28, "Steve" -> 42)
Maybe this change was taken into account considering the Scala collection literals implementation?












My LinkedIn
#1 by Mathieu on September 22, 2009 - 11:54 pm
Ruby:
myhash = {“A”=>100, “b”=>100}
#2 by Bruno on March 20, 2010 - 11:21 am
I’m still more fond of the Groovy syntax to Lists and Maps:
def list = [5, 6, 7, 8]
def map = [name:"Gromit", likes:"cheese", id:1234]