Skip to content

Instantly share code, notes, and snippets.

@theoknock
Last active April 20, 2022 20:31
Show Gist options
  • Save theoknock/ed1825b2f178b27559ec0979d663c726 to your computer and use it in GitHub Desktop.
Save theoknock/ed1825b2f178b27559ec0979d663c726 to your computer and use it in GitHub Desktop.
Sequencing blocks and methods inside a return statement.
- (int)asdf {
return ^ (int y) { // waits to return int as required by the asdf method....
int result = y * 2; // ...until all other block literals and methods return
printf("y == %d\n", y); // printf statements are inserted to indicate when a block or method returns (this returns 3rd)
return result;
}(^ int (int x) {
printf("x == %d\n", x); // returns 1st
[self recursive_block]; // returns 2nd
return x;
}(1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment