hi,
What is the naming convention for method names to clarify whether its
a get or set type of method?
tks
hi,
What is the naming convention for method names to clarify whether its
a get or set type of method?
tks
On Nov 5, 9:07 pm, “Greg H.” [email protected]
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 =, so that’s a good choice.
class Square
def height
@height
end
def height=(val)
@height = val
end
end
Note that you can do the same in a much easier way.
class Square
attr_accessor :height
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs