Re: message to nil? (very basic question)
Re: message to nil? (very basic question)
- Subject: Re: message to nil? (very basic question)
- From: Vince DeMarco <email@hidden>
- Date: Sun, 20 Jan 2002 14:50:58 -0800
On Sunday, January 20, 2002, at 08:57 AM, Ondra Cada wrote:
Andrew,
Andrew Abernathy (AA) wrote at Sat, 19 Jan 2002 19:16:39 -0800:
AA> >Is it allowed to send a message to nil or will it crash or give some
AA> >runtime errors or such things?
AA>
AA> This is not always safe!!!
It *IS* *ALWAYS* *UTTERLY* safe!!!!
What might not be safe is interpreting the return value in case it is not
convertible from id. You can _send_ a message to nil quite securely
regardless the return type, though.
Read the rest of Andrew's message a bit more carefully, he is correct.
If the nil object returns a float or a structure you might not get back 0.
0 in the case of floats or and empty stucture.
its okay for objects and ints.