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. Advertising

  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. 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. Vlajko Knezic
    Replies:
    1
    Views:
    10,626
    Joe Smith
    Mar 6, 2005
  2. Miguel Dias Moura
    Replies:
    0
    Views:
    363
    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:
    361
    =?Utf-8?B?Sm9obiBCYWlsZXk=?=
    Jun 16, 2005
  4. Niclas

    validation - indicate invalid field

    Niclas, Apr 2, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    379
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Apr 2, 2006
  5. Lewis G. Pringle, Jr.
    Replies:
    0
    Views:
    600
    Lewis G. Pringle, Jr.
    Sep 30, 2003
Loading...

Share This Page