November 2013
Beginner
325 pages
9h 47m
English
Here are some other things you can do with blocks.
The block that you created for VowelMovement does not have a return value, but many blocks will. When a block returns a value, you can get the return value by calling the block variable like a function.
Let’s look again at one of the sample blocks you saw at the beginning of the chapter:
^(double dividend, double divisor) {
double quotient = dividend / divisor;
return quotient;
}
This block takes two doubles and returns a double. To store this block in a variable, you would declare a variable of that type and assign the block to it:
// Declare divBlock variable double (^divBlock)(double,double); // Assign block to variable divBlock = ...
Read now
Unlock full access