James Britt
9/3/2006 4:29:00 PM
Jeff Rohrer wrote:
> Hi, total noob here. I'm only on page 25 of the Pick Axe book and I'm a
> little stuck:
>
> I'm running Ruby version 1.8.4 on Windows XP Home Edition. I'm entering
> code via irb.
>
> Here's the problem: I enter the following code from the book:
>
> class Song
> def initialize(name, artist, duration)
> @name = name
> @artist = artist
> @duration = duration
> end
>
> def to_s
> "Song: #@name--#@artist (#@duration)"
> end
> end
>
I just tried this on WinXP, ruby 1.8.4 (2005-12-24) [i386-mswin32]
demo.rb has the code you provided.
d:\tmp>irb
irb(main):001:0> load 'demo.rb'
=> true
irb(main):002:0> song = Song.new("Bicylops", "Fleck", 260)
=> #<Song:0x2b1a370 @name="Bicylops", @duration=260, @artist="Fleck">
irb(main):003:0> song.to_s
=> "Song: Bicylops--Fleck (260)"
irb(main):004:0>
I think you may have something different in your actual source code.
--
James Britt
"Simplicity of the language is not what matters, but
simplicity of use."
- Richard A. O'Keefe in squeak-dev mailing list