vendredi 20 mars 2015

I don't understand hashes, RUBY

This code is in my book, there are 2 lines that I don't understand, I neel help


library.rb



class Library
def initialize
@books ={} #creating a new hash
end
def addBook(book)
@books[book.category]||=[] #category is a symbol. I DONT UNDERSTAND THIS LINE
@books{book.category] << book #AND THIS ONE
end
end

Aucun commentaire:

Enregistrer un commentaire