Last active
December 19, 2015 19:09
-
-
Save capnslipp/6004177 to your computer and use it in GitHub Desktop.
Brainstorming a more Obj-C-like block syntax
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
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); |
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
^ (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