Clarification in Obj C blocks

Why is this a mistake?

float (^isFloat)(float) = ^(float d) { return d*2.0; }; 

At some point, the following error message:

 float (^isFloat)(float) = ^(float d) { return d; }; 

PLease help me understand.

+4
source share
1 answer

Since your return type in the first block is incorrect.

You defined a block to return a float , but you multiplied a float by double . If you change it to d * 2.0f , everything should work fine.

+9
source

Source: https://habr.com/ru/post/1393836/


All Articles