Skip to content

Instantly share code, notes, and snippets.

@Lewuathe
Created August 1, 2013 13:14
Show Gist options
  • Select an option

  • Save Lewuathe/6131186 to your computer and use it in GitHub Desktop.

Select an option

Save Lewuathe/6131186 to your computer and use it in GitHub Desktop.
^(int n) {
return n + 1;
};
int (^plusOne) (int) = ^(int n) {
return n + 1;
};
typedef int (^PlusOne)(int);
PlusOne plusOne = ^(int n) {
return n + 1;
};
__block int x = 100;
void (^print)(void) = ^(void) {
NSLog("%d", x);
};
print(); // 100が表示される
- (void)oneWithFunc:(int (^)(int))func {
int n = 1;
return func(n);
}
[myObject oneWithFunc:^(int n) {
return n * 2;
}];
// 1 * 2で2が返ってくる
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment