G
Guest
Greeting all,
How about a refreshingly easy question for a change....
Really, really basic question I know, but:
class Song
attr_writer :name, :artist, :duration
end
=> nil
song = Song.new("Blueberry Hill", "Fats Waller", 320)
=> ArgumentError: wrong number of arguments (3 for 0)
from (irb):24:in `initialize'
from (irb):24:in `new'
from (irb):24
However....
song = Song.new()
=> #<Song:0x2aab648>
song.name = "Blueberry Hill"
=> "Blueberry Hill"
song.name
=> "Blueberry Hill"
Have I misread / misunderstood the text? Why the errors?
SM
(Only 770 pages to go... Woohoo!)
------------------------------------------------------------------------------------------
Equinox Converged Solutions
Tel: +44 (0)1252 405 600
http://www.equinoxsolutions.com
Equinox Converged Solutions is a trading name of Synetrix Holdings Limited.
IMPORTANT NOTICE:
This message is intended solely for the use of the Individual or organisation to whom it is addressed. It may contain privileged or confidential information. If you have received this message in error, please notify the originator immediately.
If you are not the intended recipient, you should not use, copy, alter, or disclose the contents of this message. All information or opinions expressed in this message and/or any attachments are those of the author and are not necessarily those of Synetrix Holdings Limited.
Synetrix Holdings Limited accepts no responsibility for loss or damage arising from its use, including damage from virus.
-------------------------------------------------------------------------------------------
How about a refreshingly easy question for a change....
Really, really basic question I know, but:
class Song
attr_writer :name, :artist, :duration
end
=> nil
song = Song.new("Blueberry Hill", "Fats Waller", 320)
=> ArgumentError: wrong number of arguments (3 for 0)
from (irb):24:in `initialize'
from (irb):24:in `new'
from (irb):24
However....
song = Song.new()
=> #<Song:0x2aab648>
song.name = "Blueberry Hill"
=> "Blueberry Hill"
song.name
=> "Blueberry Hill"
Have I misread / misunderstood the text? Why the errors?
SM
(Only 770 pages to go... Woohoo!)
------------------------------------------------------------------------------------------
Equinox Converged Solutions
Tel: +44 (0)1252 405 600
http://www.equinoxsolutions.com
Equinox Converged Solutions is a trading name of Synetrix Holdings Limited.
IMPORTANT NOTICE:
This message is intended solely for the use of the Individual or organisation to whom it is addressed. It may contain privileged or confidential information. If you have received this message in error, please notify the originator immediately.
If you are not the intended recipient, you should not use, copy, alter, or disclose the contents of this message. All information or opinions expressed in this message and/or any attachments are those of the author and are not necessarily those of Synetrix Holdings Limited.
Synetrix Holdings Limited accepts no responsibility for loss or damage arising from its use, including damage from virus.
-------------------------------------------------------------------------------------------