2009-10-09

I like Ruby

I'm working on something at the office in which I have a client running in C# .net code and a web server running with Ruby On Rails. Occasionally, when switching between them, I'll sometimes think of a Ruby solution to some code I'm writing in C#.

Recently, I had a loop that looks like this:
bool matchedOne = false;
foreach ( ScalarMatch match in MatchSet.Matches )
{
if ( match.PerformMatch(check) )
{
matchedOne = true;
break;
}
}
if ( ! matchedOne )
return null;

And I realized that the Ruby method would look like this:
return nil if not matchSet.matches.all? {|m| m.performMatch(check) }

I like Ruby.