Is there something I am missing?

Hi Darushin,

Darushin wrote:

First the Working Code:

placeholder = 0 while(@record_album[placeholder])

From Pickaxe, p93, "Ruby has a simple definition of truth. Any value that is not nil or the constant false is true." The while loop executes until @record_album[placeholder] evaluates to nil.

while(@record_album[placeholder].parentid == Parent.id) gives me a "You have a nil object when you didn't expect it! The error occurred while evaluating nil.parentid"

This error occurs because Ruby does not allow you to invoke a method on a nil object. Your working code avoids this by performing the test for a nil object prior to attempting to invoke the .parentid method.

hth, Bill

Hi Ben,

Darushin wrote:

Thank you so much. I figured there was a reason for this behavior and it was driving me nuts to figure out why it was doing this.

You're welcome. Glad to help.

Best regards, Bill