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.
No comments:
Post a Comment