Collection Initializers
Scripting languages like Ruby and Groovy recognize the importance of collections like lists and maps, treating them almost like first class objects. By doing so, they make it really easy to create collections like these and populate them all in one step.
For example, in Ruby here is how this is done:
# create a list
lst = [1, 2, 3, 4, 5]
# create a map
map = { "one" => 1, "two" => 2, "three" => 3 }
Not surprisingly, we see very similar syntax in Groovy...
// create a list
def lst = [1, 2, 3, 4, 5]
// create a map
def map = ["one":1, "two":2, "three":3]
And in case you missed it, one of the changes in C# 3.0 was the ability to initialize collections similar to the way it's done in these scripting languages (though the syntax is not *quite* as clean):
// create a list
var lst = new List<int> { 1, 2, 3, 4, 5 };
// create a map
var map = new Dictionary<string, int> { {"one", 1}, {"two", 2}, {"three", 3} };
IMO, the new collection initializers (along with property initializers) are one of the nicest changes in the new version of the .Net framework. And since I'm feeling nice, I won't show how this is accomplished in native Java. 
Saturday, June 14, 2008 8:23:10 PM (Eastern Standard Time, UTC-05:00)
C# | Groovy | Ruby