Skip to content

Instantly share code, notes, and snippets.

@capnslipp
Last active December 19, 2015 19:09
Show Gist options
  • Save capnslipp/6004177 to your computer and use it in GitHub Desktop.
Save capnslipp/6004177 to your computer and use it in GitHub Desktop.
Brainstorming a more Obj-C-like block syntax
double (^multiplyTwoValues)(double, double) = ^(double firstValue, double secondValue) {
return firstValue * secondValue;
};
double result = multiplyTwoValues(2, 4);
// or
typedef double (^CombineTwoValuesBlock)(double firstValue, double secondValue);
CombineTwoValuesBlock multiplyTwoValues = ^(double firstValue, double secondValue) {
return firstValue * secondValue;
};
double result = multiplyTwoValues(2, 4);
^ (double)multiplyValue:(double)firstValue and:(double)secondValue {
return firstValue * secondValue;
};
double result = [^multiplyValue:2 and:4];
// or
typedef ^ (double)CombineValue:(double)firstValue and:(double)secondValue;
^CombineValue:and: multiplyValue:and: = ^(double firstValue, double secondValue) {
return firstValue * secondValue;
};
double result = [^multiplyValue:2 and:4];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment