PDA

View Full Version : [SOLVED] ruby, wrong number of arguments for initilize



cybo
September 13th, 2009, 03:01 AM
i have a peace of code in ruby and when i run i get the error below. the funny thing is that i took this code straight out of the textbook. can any one help me out

song_test.rb:2:in `initialize': wrong number of arguments (3 for 0) (ArgumentError)
from song_test.rb:2:in `new'
from song_test.rb:2

here is the code

song.rb


class Song
def initilize(name, artist, duration)
@name = name
@artist = artist
@duration = duration
end

attr_reader :name, :artist, :duration
end


song_test.rb


require 'song.rb'
my_song = Song.new("Worthy is the Lamb", "Hillsong", "300")
puts my_song.name
puts my_song.artist
puts my_song.duration

loell
September 13th, 2009, 03:08 AM
def initialize(name, artist, duration) ;)

cybo
September 13th, 2009, 03:16 AM
def initialize(name, artist, duration) ;)

:D Thanks