Skip to content

Utility

General-purpose utility functions.

Returns the same value passed as the argument.

id stooge = OKV({@"name", @"moe"});
B result = _.identity(stooge) == stooge;
// => YES

Returns YES if the value is truthy.

B result = _.identityTruthy(@"hello");
// => YES
B result = _.identityTruthy(@"");
// => NO

Invokes the iterator n times.

_.times(3, ^(I n) {
NSLog(@"iteration %ld", n);
});
// => logs 0, 1, 2

Generates a globally unique ID.

S* id1 = _.uniqueId(@"contact_");
// => "contact_1"
S* id2 = _.uniqueId(@"contact_");
// => "contact_2"

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"