Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clarification in Obj C Blocks

Why this is an Error ?

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

At the sometime, the following is error free,

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

PLease help me understand.

like image 482
Futur Avatar asked Jan 18 '23 15:01

Futur


1 Answers

Because your return type on the first block is incorrect.

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

like image 62
Joshua Weinberg Avatar answered Jan 25 '23 21:01

Joshua Weinberg