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

G

Greg Hauptmann

hi,

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

tks
 
Y

Yossef Mendelssohn

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top