Created
July 4, 2011 03:18
-
-
Save hechien/1062862 to your computer and use it in GitHub Desktop.
Make block as a function in JavaScript & Objective-C
This file contains 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
var run_to_me = function(lonely){ | |
if(lonely) | |
console.log("whenever you're lonely"); | |
else | |
console.log("f**k off"); | |
} | |
run_to_me(true); | |
run_to_me(false); |
This file contains 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
// BTW, "Run to me" is a song sang by Bee Gees. | |
void (^run_to_me)(BOOL) = ^(BOOL lonely){ | |
if(lonely) NSLog(@"whenever you're lonely"); | |
else NSLog(@"f**k off"); | |
}; | |
run_to_me(YES); | |
run_to_me(NO); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment