Extend Class to include attr?

Discussion in 'Ruby' started by Mark T, Apr 15, 2010.

  1. Mark T

    Mark T Guest

    Can I extend a class to add an attr_accessor?
    So that getter & setter are created?

    MarkT
    Mark T, Apr 15, 2010
    #1
    1. Advertising

  2. On 15.04.2010 05:30, Mark T wrote:
    > Can I extend a class to add an attr_accessor?
    > So that getter& setter are created?


    Yes.

    > How?


    class AnyClass
    attr_accessor :foo
    end

    Kind regards

    robert

    --
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
    Robert Klemme, Apr 15, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9iIEtheQ==?=

    Extend the Membership Provider to include more user data

    =?Utf-8?B?Um9iIEtheQ==?=, Jan 5, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    7,965
    Scott Allen
    Jan 6, 2006
  2. Andreas Bogenberger
    Replies:
    3
    Views:
    879
    Andreas Bogenberger
    Feb 22, 2008
  3. aspineux
    Replies:
    3
    Views:
    203
    aspineux
    Aug 18, 2011
  4. Gioele Barabucci

    class methods like attr:

    Gioele Barabucci, Jan 21, 2006, in forum: Ruby
    Replies:
    3
    Views:
    92
    Wilson Bilkovich
    Jan 23, 2006
  5. rlf
    Replies:
    1
    Views:
    82
    Gary Wright
    May 22, 2009
Loading...

Share This Page