Utility
General-purpose utility functions.
identity
Section titled “identity”Returns the same value passed as the argument.
id stooge = OKV({@"name", @"moe"});B result = _.identity(stooge) == stooge;// => YESidentityTruthy
Section titled “identityTruthy”Returns YES if the value is truthy.
B result = _.identityTruthy(@"hello");// => YES
B result = _.identityTruthy(@"");// => NOInvokes the iterator n times.
_.times(3, ^(I n) { NSLog(@"iteration %ld", n);});// => logs 0, 1, 2uniqueId
Section titled “uniqueId”Generates a globally unique ID.
S* id1 = _.uniqueId(@"contact_");// => "contact_1"
S* id2 = _.uniqueId(@"contact_");// => "contact_2"result
Section titled “result”If the property is a function, invoke it; otherwise return it.
O* obj = OKV({@"cheese", @"crumpets"}, {@"stuff", ^{ return @"nonsense"; }});
S* result = _.result(obj, @"cheese");// => "crumpets"
S* result = _.result(obj, @"stuff");// => "nonsense"