« Back to Log

Rubyblood through your .NET veins with a vengeance

Posted by myself on June 28, 2008

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

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

No comments registered

Random Quote

Man has to suffer. When he has no real
afflictions, he invents some.

Jose Marti

» ...

koffeinfrei on identi.ca

icon
2010-07-26 11:46:49
Everybody needs a fishbowl: “YouTube - Barry Schwartz: The paradox of choice” — http://www.youtube.com/watch?v=VO6XEQIsCoM
icon
2010-06-18 09:07:19
@kentbrew: what i'm i missing? the #identica-badge doesn't show my entries on http://koffeinfrei.org/
icon
2010-06-16 08:00:30
“YouTube - BP Spills Coffee” — http://www.youtube.com/watch?v=2AAa0gd7ClM
icon
2010-06-01 20:03:29
"The surprising truth about what motivates us”: http://www.youtube.com/watch?v=u6XAPnuFjJc&feature=player_embedded
icon
2010-05-20 21:11:48
“Sumatra PDF is a slim, free, open-source PDF viewer for Windows” — http://blog.kowalczyk.info/software/sumatrapdf/index.html

Ying and Yang

where I am
where I should be