method names-how to indicate get vs set type of method?

Discussion in 'Ruby' started by Greg Hauptmann, Nov 6, 2008.

  1. hi,

    What is the naming convention for method names to clarify whether its
    a get or set type of method?

    tks

    --
    Sent from my mobile device
     
    Greg Hauptmann, Nov 6, 2008
    #1
    1. Advertisements

  2. On Nov 5, 9:07=A0pm, "Greg Hauptmann" <>
    wrote:
    > What is the naming convention for method names to clarify whether its
    > a get or set type of method?


    Ruby methods can end in =3D, so that's a good choice.

    class Square
    def height
    @height
    end

    def height=3D(val)
    @height =3D val
    end
    end

    Note that you can do the same in a much easier way.

    class Square
    attr_accessor :height
    end

    --
    -yossef
     
    Yossef Mendelssohn, Nov 6, 2008
    #2
    1. Advertisements

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. Vlajko Knezic
    Replies:
    1
    Views:
    10,996
    Joe Smith
    Mar 6, 2005
  2. Miguel Dias Moura
    Replies:
    0
    Views:
    469
    Miguel Dias Moura
    May 24, 2004
  3. =?Utf-8?B?Sm9obiBCYWlsZXk=?=

    Can you still indicate to distribute files locally in ASP.Net 2.0

    =?Utf-8?B?Sm9obiBCYWlsZXk=?=, Jun 16, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    449
    =?Utf-8?B?Sm9obiBCYWlsZXk=?=
    Jun 16, 2005
  4. Jeff Kish
    Replies:
    12
    Views:
    2,758
    Sudsy
    Oct 1, 2004
  5. Lewis G. Pringle, Jr.
    Replies:
    0
    Views:
    751
    Lewis G. Pringle, Jr.
    Sep 30, 2003
  6. Howard
    Replies:
    2
    Views:
    544
    Michiel Salters
    Jul 4, 2003
  7. Rolf Magnus
    Replies:
    1
    Views:
    452
    ding feng
    Jul 4, 2003
  8. Ravi
    Replies:
    7
    Views:
    1,232
    bodenstorfer
    Jul 30, 2011
Loading...