怎么才能输出内容,而不是内存地址
class SongList
def initialize
@songs = Array.new
end
def deleteFirst
@songs.shift
end
def deletelast
@songs.pop
end
def append(aSong)
@songs.push(aSong)
self
end
def [](key)
if key.kind_of?(Integer)
@songs[key]
else
puts "123123"
end
end
end
class Song
def intiailze(name,artist,duration)
@name = name
@artist = artist
@duration = duration
end
end
list = SongList.new
list.append(Song.new("title1","artist1",1))
list.append(Song.new("title2","artist2",2))
list.append(Song.new("title3","artist3",3))
list.append(Song.new("title4","artist4",4))