The Music Library CLI Lab is a lab where one is tasked with creating a music library that is easily accessible to search through, add songs, delete songs, and navigate through the command line interface. This is one of the final projects in the Ruby track for the Flatiron School Community-Based Bootcamp.
Here’s a breakdown of the instructions:
Create an Artist, Song, and Genre class
Map Relationships Between Classes
def artist=(artist) #artist.name = @name #artist.add_song(@@all) self.artist.add_song(self) end
def artist=(artist) #artist.name = @name #artist.add_song(@@all) if artist == nil @artist = artist elsif artist != nil @artist = artist artist.add_song(self) end end
The above edit accounts for what to do if artist is nil, as well as not nil. The problem I was having before is that artist.add_song(self) was not sufficient because I was not defining the artist as equal to an instance variable of @artist first.