Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created June 12, 2013 18:16
Show Gist options
  • Save stevenharman/5767741 to your computer and use it in GitHub Desktop.
Save stevenharman/5767741 to your computer and use it in GitHub Desktop.
A `tap` method for Objective-C, as inspired by Ruby. Thanks, @coreyhaines.
#import <Foundation/Foundation.h>
@interface NSObject (Tap)
- (id)tap:(void (^)(id))block;
@end
#import "NSObject+Tap.h"
@implementation NSObject (Tap)
- (id)tap:(void (^)(id))block
{
block(self);
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment