The printTable(_:)
function has a bug: It crashes if any of the data items are longer than the label of their column.
Try changing the age of a person to 1,000 to see this happen. Fix the bug.
Note
Your solution will likely result in incorrect table formatting; that is fine for now. You will fix the formatting in the gold challenge, below.
Create a new type, BookCollection
, that conforms to TabularDataSource
.
Calling printTable(_:) on a book collection should show a table of books with columns for titles, authors, and average reviews.
Note
Unless all the books you use have very short titles and author names, you will need to have completed the previous challenge!
After you fixed the crashing bug in the first challenge, the table rows and columns were likely misaligned. Fix your solution to correctly align the table rows and columns. Verify that your solution does not crash with values longer than their column labels.