From: Amir Ebrahimifard on
Hi
Please help someone that knows C++ , and my question :
Does "attribute" in ruby is same as "private member" in c++ ? if no
please exactly explain me what is the concept of "attribute" in ruby?
--
Posted via http://www.ruby-forum.com/.

From: a.bovanenko on
Hi
Attributes are as accessor methods for private field. You
can use it for setting and getting value.
-----Original Message-----
From: Amir Ebrahimifard
Sent: 08.08.2010, 20.36
To: ruby-talk ML
Subject: Attributes in class


Hi
Please help someone that knows C++ , and my question :
Does "attribute" in ruby is same as "private member" in c++ ? if no
please exactly explain me what is the concept of "attribute" in ruby?
--
Posted via http://www.ruby-forum.com/.



From: Sniper Abandon on
Amir Ebrahimifard wrote:
> Hi
> Please help someone that knows C++ , and my question :
> Does "attribute" in ruby is same as "private member" in c++ ? if no
> please exactly explain me what is the concept of "attribute" in ruby?

i thing you are talking about rails model
attribute is a instance variable of that class

--
Posted via http://www.ruby-forum.com/.

From: Brian Candler on
Amir Ebrahimifard wrote:
> Hi
> Please help someone that knows C++ , and my question :
> Does "attribute" in ruby is same as "private member" in c++ ? if no
> please exactly explain me what is the concept of "attribute" in ruby?

You're perhaps thinking of accessor methods. The following code:

class Foo
attr_accessor :bar
end

does effectively the same as this:

class Foo
def bar
@bar
end
def bar=(val)
@bar = val
end
end

For learning about the basics of Ruby, I strongly recommend the book
Programming Ruby. The first edition is available to view online for
free:
http://www.ruby-doc.org/docs/ProgrammingRuby/

Since you're already a programmer you should find this very accessible.

HTH,

Brian.
--
Posted via http://www.ruby-forum.com/.