|Problems? Is your data what you think it is?|
I am new to Moose and I could use a little help on how to fix this.
FYI, I completely agree with the error, just need suggestions on how to fix the code.
The code models somebody's library, with books that the owner has read and books that he has not. At the beginning, all books are meant to be 'unread', and as he starts reading, he moves them into the 'read' pile.LibraryTest.pm
Main.pl - already have a ref to a list of books saved in $allbooks. Please note that the second attribute, read_books, is not initializedmy $Libr = LibraryTest->new(unread_books => $allbooks);
....he reads the first book and wants to move it from the unread pile to the read pile...$Libr->MoveBook($Libr->PopBook);
This is where disaster strucks .. the second attribute of the object is undef... how do I initialize it with a reference to an empty array of Book?
Or maybe it's better to modify the constructor somehow so that for when the second attribute is not explicitly given ?Many thanks for any suggestion :)
In reply to Can't call method "MoveBook" on an undefined value by bgu