[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: what's wrong with this use of the index to clean a list?
From: |
jalex |
Subject: |
Re: what's wrong with this use of the index to clean a list? |
Date: |
Wed, 27 Oct 1999 21:37:57 -0700 (PDT) |
Paul E. Johnson writes:
> Here is what I don't get: what does the processing inside the loop do
> when it gets passed a nil member value? Suppose inside that for loop
> there is a command
> [member doSomething];
> ?
> Should the program be testing every "member" to see if it is not nil?
> Without doing that, I suppose I would expect a crash at run time saying
> "nil does not respond to doSomething"? But I have not seen such a
> crash.
If my understanding of the Objective-C language is correct, sending
messages to nil doesn't cause the program to crash. On the contrary,
the message is ignored and the program continues on its merry way.
This is a "feature" of the language.
So, although sending messages to nil doesn't hurt anything,
it is almost always a sign that something else is awry in the
program. I bet, though, that someone else could cook up an example
showing the Great Benefits of being able to send messages to nil
without having the program crash.
Cheers,
Jason
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.