M
Mike Onofrietto
Hello World.
This is my first forum membership, and first post.
I am learning Ruby.
It seems to be a very elegant an encompassing OO language.
I'm reading Thomas & Hunt: Classes, Objects, and Variables on-line.
See attached.
Regarding the following by the authors, and attached I see no
correlation.
However I've had very good results with attr_accessor.
Please help.
class Song
def name
@name
end
def artist
@artist
end
def duration
@duration
end
end
aSong =3D Song.new("Bicylops", "Fleck", 260)
aSong.artist =C2=BB "Fleck"
aSong.name =C2=BB "Bicylops"
aSong.duration =C2=BB 260
------------------
class Song
attr_reader :name, :artist, :duration
end
aSong =3D Song.new("Bicylops", "Fleck", 260)
aSong.artist =C2=BB "Fleck"
aSong.name =C2=BB "Bicylops"
aSong.duration =C2=BB 260
Attachments:
http://www.ruby-forum.com/attachment/5878/TH_QA_1.doc
http://www.ruby-forum.com/attachment/5879/attr.rb
-- =
Posted via http://www.ruby-forum.com/.=
This is my first forum membership, and first post.
I am learning Ruby.
It seems to be a very elegant an encompassing OO language.
I'm reading Thomas & Hunt: Classes, Objects, and Variables on-line.
See attached.
Regarding the following by the authors, and attached I see no
correlation.
However I've had very good results with attr_accessor.
Please help.
class Song
def name
@name
end
def artist
@artist
end
def duration
@duration
end
end
aSong =3D Song.new("Bicylops", "Fleck", 260)
aSong.artist =C2=BB "Fleck"
aSong.name =C2=BB "Bicylops"
aSong.duration =C2=BB 260
------------------
class Song
attr_reader :name, :artist, :duration
end
aSong =3D Song.new("Bicylops", "Fleck", 260)
aSong.artist =C2=BB "Fleck"
aSong.name =C2=BB "Bicylops"
aSong.duration =C2=BB 260
Attachments:
http://www.ruby-forum.com/attachment/5878/TH_QA_1.doc
http://www.ruby-forum.com/attachment/5879/attr.rb
-- =
Posted via http://www.ruby-forum.com/.=