Skip to content

Instantly share code, notes, and snippets.

@onevcat
Created September 20, 2012 09:24
Show Gist options
  • Save onevcat/3754886 to your computer and use it in GitHub Desktop.
Save onevcat/3754886 to your computer and use it in GitHub Desktop.
block outer var use
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