This is from apple blocks docs and I am having difficulty understanding this please can any one explain it
If you don’t explicitly declare the return value of a block
expression, it can be automatically inferred from the contents of the
block. If the return type is inferred and the parameter list is void,
then you can omit the (void) parameter list as well. If or when
multiple return statements are present, they must exactly match (using
casting if necessary).
1) If you don’t explicitly declare the return value of a block expression, it can be automatically inferred from the contents of
the block
The block
can also be written as
without saying the return type. The return type is automatically inferred. It is true for blocks that returning non void values.
2) If the return type is inferred and the parameter list is void, then you can omit the (void) parameter list as well
This is bit tough to understand and confusing, since documentation specifically saying
I believe this kind of blocks is possible.
where return value is inferred, and because of that, a void is not needed. I am not sure about this, so would like some clarification.
3) If or when multiple return statements are present, they must exactly match (using casting if necessary).
Simply means, a block must return only one type of data. It can’t return an int and float.