Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <Block.h>
- void* make_block (int start)
- {
- __block int counter = start;
- int (^closure)() = ^{
- int res = counter;
- counter++;
- return res;
- };
- return Block_copy (closure);
- }
- int main ()
- {
- int(^closure)() = make_block (10);
- int i;
- for (int i=0; i<10; i++)
- printf ("%i\n", closure());
- Block_release (closure);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement