Created
September 20, 2012 09:27
-
-
Save onevcat/3754895 to your computer and use it in GitHub Desktop.
local block
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
// Use the __block storage modifier to allow changes to 'price' | |
__block float price = 1.99; | |
float (^finalPrice)(int) = ^(int quantity) | |
{ | |
return quantity * price; | |
}; | |
int orderQuantity = 10; | |
price = .99; | |
NSLog(@"With block storage modifier - 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