@books ={}
Above line will create a new Hash
@books[book.category]||=[]
This means @books is a Hash and book.category is it's key and if that key not exist assign an empty array
||= -> So this means or-equals
|| means if @books has value it will not assign empty array, else it will put an empty array
So if @books[book.category] is a Array, in which you can insert as many category values
In this line we will insert book value into the hash, where book.category is the key
@books[book.category] << book
If you try this
@books ={}
@books[book.category].push(book) # This will give you the error `undefined method 'push' for nilclass`
because
@books[book.category].class will return NilClass