On Mar 2, 2006, at 9:33 AM, Charlie Bowman wrote:

> I know this is the ruby list and not the rails list but it would be  
> nice
> if we didn't have to add code to our views to rescue nils.  I guess  
> you
> could add the method each if you to the nil class right?

You can, sure.  Whether or not it is a good idea is the question.  ;)

Currently, when you call each() on nil, it explodes.  This is a good  
thing, because it takes you right to the problem.  You were expecting  
to have an Enumerable, but you really have a nil.

If we take that away, Ruby will start silently accepting what are  
most likely mistakes.  While that may keep you from typing (enum ||  
[]).each... in some places, it will prevent Ruby from catching real  
errors in others.  Better that we explicitly state that nil is okay  
in this case, and let Ruby watch our back for us the rest of the  
time, don't you think?

James Edward Gray II