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