Created
September 20, 2012 09:24
-
-
Save onevcat/3754886 to your computer and use it in GitHub Desktop.
block outer var use
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
float price = 1.99; | |
float (^finalPrice)(int) = ^(int quantity) | |
{ | |
// Notice local variable price is | |
// accessible in the block | |
return quantity * price; | |
}; | |
int orderQuantity = 10; | |
NSLog(@"Ordering %d units, final price is: $%2.2f", orderQuantity, finalPrice(orderQuantity)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment