Last active
April 20, 2022 20:31
-
-
Save theoknock/ed1825b2f178b27559ec0979d663c726 to your computer and use it in GitHub Desktop.
Sequencing blocks and methods inside a return statement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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