mneorr/ObjectiveSugar — pull request #14 by nadinengland (2013-01-30 19:05:58+00:00)
Title: Dictionary map

I was working with `ActiveRecord` validation errors and needed to turn them into a string, `NSDictionary#map` seemed like a reasonable solution. See Ruby `Hash#map` (inherited from [`Enumerable`](http://www.ruby-doc.org/core-1.9.3/Enumerable.html#method-i-map)) for a direct comparision.

**JSON Response**

```JSON
{
"username" : [ "already taken" ],
"password" : [ "is too short (minimum is 8 characters)", "not complex enough" ],
"email" : [ "can't be blank" ]
}
```

**Ruby**

```Ruby
errors map do |attribute, reason|
"%s %s" % attribute, reasons.join(", ")
end
```

**Objective-C**

```Objective-C
NSArray* sentences = [errors map:^(id attribute, id reasons) {
return NSStringWithFormat(@"%@ %@", attribute, [reasons join:@", "]);
}];

[sentences join:@"; "];
// username already taken; password is too short (minimum is 8 characters), not complex enough; email can't be blank
```

N.B. I'm only a recent adopter of ObjectiveSugar but I fell in love immediately, thank you for such a lovely library.