Hi Søòen,
Looks like you've spelt initialize incorrectly. Also your last line should
be :
puts s.inspect
to get some output
So try this:
===================================
class Person
def initialize(name, street, phone, age)
@name = name
@street = street
@phone = phone
@age = age
end
end
s = Person.new( "Soeren", "My Street", "12345678", "21" )
puts s.inspect
=======================================
and you should get something like this:
#<Person:0xa034608 @age="21", @phone="12345678", @street="My Street",
@name="Soeren">
regards,
Martin
-----Original Message-----
From: Søòen Munk Skrøäer [mailto:s_skroeder / hotmail.com]
Sent: Monday, 25 June 2001 9:03 AM
To: ruby-talk / ruby-lang.org
Subject: [ruby-talk:16829] Totally newbie seeks a bit of help
Hi ...
I've just downloaded the 'One-Click-windows installer' of Ruby (ver. 1.6.3)
.....
I've wanted to see if i could get this working, so i read a bit in the "Ruby
book" on RubyCentral.com ....
I've made a class, called Person,
## contents of file Person.rb ##
------8<------8<------8<------8<------8<------8<------8<------
class Person
def initalize(name, street, phone, age)
@name = name
@street = street
@phone = phone
@age = age
end
end
s = Person.new( "Soeren", "My Street", "12345678", "21" )
s.inspect
------8<------8<------8<------8<------8<------8<------8<------
When i choose "Run file" in RubyWin, i get this response in a 'console'
window
------8<------8<------8<------8<------8<------8<------8<------
E:\Udvikling\Ruby\Test_001\Person.rb:10:in `initialize': wrong # of
arguments(4 for 0)(ArgumentError)
from E:\Udvikling\Ruby\Test_001\Person.rb:10:in `initialize'
from E:\Udvikling\Ruby\Test_001\Person.rb:10:in `new'
from E:\Udvikling\Ruby\Test_001\Person.rb:10
from E:\Udvikling\Ruby\Test_001\Person.rb:12
------8<------8<------8<------8<------8<------8<------8<------
What am i doing wrong.... The Person-class should take 4 arguments ,,,
shouldn't it ??????
And where does the program excecution start ( I'm a Java and C++ programmer,
so i'm used to "void main" :-))))
/Søòen Munk Skrøäer
Odense, Denmark