I use NAN for things like this. (Not A Number )

        if( !sound ) return NAN;

and your test would then be

        if( isnan( sound ) ) return nil;

provided you aren't doing any divisions by zero similar things in your code 
which could cause the value to be NaN, it's a useful marker for "I don't care"

On 30-Jan-2010, at 8:44 AM, Chunk 1978 wrote:

> i'm almost 100% sure it's not possible to return a nil on basic data
> types, but just incase i'll post the question.
> 
> ------------------------------------------------------
> - (float)panForSoundWithName:(NSString *)soundName
>       {
>       OpenALSound *sound = [soundDictionary objectForKey:soundName];
>       if (!sound) return 0.0f;        
>       return sound.pan;
>       }
> ------------------------------------------------------
> 
> so above i'd like to write "if (!sound) return nil;".  my reasoning is
> because some attributes to a sound object (like pan) are created only
> when the sound is initialized.  if there is no sound object than there
> should also be no pan value to return.  unfortunately, the float
> default 0.0f is also the default value for pan (range from -1.0 to
> 1.0).
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
> 
> This email sent to r...@rols.org

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to