Hi all,
For some reason, when I run the to-many relationships program, I get a different output than the book:
Employees: (
"<Employee 0: 401 in assets>",
"<Employee 1: 384 in assets>",
"<Employee 2: 486 in assets>",
"<Employee 3: 0 in assets>",
"<Employee 4: 503 in assets>",
"<Employee 5: 1135 in assets>",
"<Employee 6: 0 in assets>",
"<Employee 7: 0 in assets>",
"<Employee 8: 904 in assets>",
"<Employee 9: 452 in assets>"
)
Giving up ownership of one employee
Deallocating <Employee 5: 1135 in assets>
Notice how after giving up ownership of employee 5, only the BNREmployee instance is deallocated. Employee 5’s BNRAssets for some reason are not…
It is only after employees = nil, that everything (including employee 5’s assets) get deallocated.
Giving up ownership of arrays
Deallocating <Employee 0: 401 in assets>
Deallocating <Employee 1: 384 in assets>
Deallocating <Employee 2: 486 in assets>
Deallocating <Employee 3: 0 in assets>
Deallocating <Employee 4: 503 in assets>
Deallocating <Employee 6: 0 in assets>
Deallocating <Employee 7: 0 in assets>
Deallocating <Employee 8: 904 in assets>
Deallocating <Employee 9: 452 in assets>
Deallocating <Laptop 9: 503>
Deallocating <Laptop 8: 486>
Deallocating <Laptop 6: 452>
Deallocating <Laptop 5: 435>
Deallocating <Laptop 7: 469>
Deallocating <Laptop 3: 401>
Deallocating <Laptop 2: 384>
Deallocating <Laptop 0: 350>
Deallocating <Laptop 1: 367>
Deallocating <Laptop 4: 418>