On Sat, Sep 1, 2012 at 2:20 PM, Rubyist Rohit <[email protected]> wrote:
> @Robert:
>
> So what I followed is if 'attr_accessor' is used, there is no need to
> create Properties. But the confusion now arises how Ruby properties are
> different than methods. The way of writing both are same.
>
> In my code in original post, I have a property:
>
> def name
>   @name
> end
>
> Is this a property or a method?

"name" is a method and "@name" is an instance variable.  You can view
this as a read only property.  It's the same as just doing
"attr_reader :name" btw.  "Method" and "instance variable" are
technical terms while "property" is more abstract - it describes the
concept that an instance has some properties (which are typically
implemented with accessor methods and instance variables).

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to