Shannon Fang <xrfang / hotmail.com> wrote:

> As a dynamic language, Ruby is much more flexible and easier than other
> language I use, for example, Delphi. However, there is a "intrinsic" problem
> in ruby programming -- a typical error I get again and again:
> 
> private method `split' called for nil:NilClass
> 
> The following statement:
> 
> array.pop.split(',')
> 
> will generate this error if array is empty.

If my goal is that I just want skip the step if it can't be done, I like
this kind of thing:

 array.pop.split(',') if array.last

If array itself could be nil then I have to add:

 puts array.pop.split(',') if array and array.last

m.
-- 
matt neuburg, phd = matt / tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com