Adding columns one row at a time is a lot simpler. Below we will add columns to two of of our rows, but not the rest:
@Bookshelf = (
[" # ", " Author ", " Title ", " Genre ", " Rating ", " Location "],
[' 1 ', ' Stephen King ', ' It ', ' Horror ', ' 5 ', ' Top '],
[' 2 ', ' Clive Barker ', ' Imajica ', ' Horror ', ' 5 ', ' Top '],
[' 3 ', ' Neil Gaiman ', ' American Gods ', ' Dark Fantasy ', ' 5 ',
' Top '],
[' 4 ', ' Dean Koontz ', ' Tick-Tock ', ' Horror ', ' 1 ', '
[' 5 ', ' Charles Bukowski ', ' Letters from a Dirty Old Man ', '
Literature ', ' 5 ', ' Top '],
[' 6 ', ' Chuck Pahluniak ', ' Fight Club ', ' Dark Fantasy ', ' 5 ',
' Middle ']
Here we get the following output:
1 Stephen King It Horror 5 Top READ
2 Clive Barker Imajica Horror 5 Top UNREAD
3 Neil Gaiman American Gods Dark Fantasy 5 Top
Note that the last row we printed did not have the read/unread column, because we did not add it.
Well that's it for this article. In our next article we will wrap up our discussion of lists and hashes (until a more advanced tutorial at any rate). Hope to see you there.
blog comments powered by Disqus