free software, web technologies and heavy metal coding (and ruby of course)

ruby blood through your .net veins with a vengeance

In my last blog entry i totally neglected the fact that there are lamda expressions. This nice little C# 3.0 feature makes anonymous methods much more readable. With that in mind, we can make our Times method much nicer.

Example 1: Ruby style iterator with lambda expression

2.Times( number => { Console.WriteLine("> " + number); } ); 

Compared to the former syntax, it increases readability considerably.

Example 2: Ruby style iterator with bare delegate

    delegate(int number)   
        Console.WriteLine("> " + number);