Armin,
Thanks, that does fix my error, but I was sort of under the impression
that attr_reader did that for you in the pick axe book I see:
class Song
attr_reader :name, :artist, :duration
end
aSong = Song.new("Bicylops", "Fleck", 260)
but entering this into irb shows me it is incorrect. Thanks for
solution!
Erik
> -----Original Message-----
> From: Armin Roehrl [mailto:armin / approximity.com]
> Sent: Saturday, November 03, 2001 3:35 PM
> To: ruby-talk ML
> Subject: [ruby-talk:24292] Re: Newbie wrong # of arguments(4 for 0)
> question
>
>
> Hi,
>
> what about adding initialize to Revision?
> --
> class Revision
> attr_reader :revision, :date, :name, :log
> def initialize(revision,date,name,log)
> @revision,@date,@name,@log=revision,date,name,log
> end
> end
> ---
>
> Bye,
> Armin
>
> On Saturday 03 November 2001 22:17, you wrote:
> > Well I've finally found an excuse to write some ruby, and I
> haven't made it
> > far before
> > I've gotten myself stuck. I remember a joke about the
> arguments error from
> > Ruby Conf,
> > but can't remember the punch line :(
> >
> > I'm sure I am making some simple little mistake, but I have no
> pair so I am
> > at a loss.
> > If anyone can offer assistance I would be most appreciative.
> >
> > --
> > Erik Meade emeade / objectmentor.com
> > Senior Consultant Object Mentor, Inc.
> > http://www.junit.org
> >
> >
> >
> >
> > Here is my test:
> > =========================
> > require 'revision'
> > require 'runit/testcase'
> > require 'runit/assert'
> > require 'runit/cui/testrunner'
> >
> > class TestRevision < RUNIT::TestCase
> >
> > def setup
> > super
> > end
> >
> > def test_equals
> > aRevision = Revision.new("1.4", "2001/10/21 02:30:18", "kbeck",
> > "Enhanced TextRunnerTest to catch missing return values.")
> > bRevision = Revision.new("1.4", "2001/10/21 02:30:18", "kbeck",
> > "Enhanced TextRunnerTest to catch missing return values.")
> > assert_equals(aRevision, bRevision)
> > end
> > end
> >
> > RUNIT::CUI::TestRunner.run(TestRevision.suite)
> > ==========================
> >
> > And the file I'm testing:
> >
> > ==========================
> > class Revision
> > attr_reader :revision, :date, :name, :log
> > end
> > ==========================
> >
> > And of course, the error:
> >
> > ==========================
> > $ ruby test_revision.rb
> >
> > TestRevision#test_equals E.
> > Time: 0.0
> > FAILURES!!!
> > Test Results:
> > Run: 1/1(0 asserts) Failures: 0 Errors: 1
> > Errors: 1
> > test_revision.rb:13:in `initialize'(TestRevision): wrong # of
> arguments(4
> > for 0)
> > (ArgumentError)
> > from test_revision.rb:13:in `new'
> > from test_revision.rb:13:in `test_equals'
> > from test_revision.rb:19
> > ==========================
>
> --
> Armin.
>
> -----------------------------------------------
> Armin Roehrl, http://www.approximity.com
> "The best way to predict the future is to invent it."
> --Alan Kay