Okay, it's lame, but still:
53 return Array.Find<ISystemUnderTest>(
54 _systems,
55 delegate(ISystemUnderTest system)
56 {
57 return system.Name == systemName;
58 });
where _systems is an array of ISystemUnderTest[] and systemName was an argument to the method that contains this code.
Somebody will have to correct me, but I think the Ruby equivalent (they call them "blocks") would look like this:
systems.Find (|system| {system.name == name})
Ruby is definitely cleaner, but I'm happy to have some of this stuff in C# now. I was playing quite a bit with Prototype in Javascript a couple months back and got hooked on the functional idioms like this method below:
table.drawPage = function(iterator, columns){
this.clear();
columns.each( function(column){
this.createHeader(column);
}.bind(this));
while (subject = iterator.next()){
this.drawRow(columns, subject);
}
}
The code "columns.each( function(column){ …" is the closure. This calls the current class's createHeader() method on each member of the columns array. Before you run off and try this in Javascript, it's Prototype that extends the Javascript Array object with a bunch of "Ruby-isms" like this. You'll need to grab the Prototype library first.
Check out Martin Fowler's explanation of closures for an explanation. I'm really looking forward to the C# 3.0 features now. I'm skeptical of much of the Microsoft canon, but I'm sincerely in awe of Anders Hejlsberg.