- Should be all in lowercase
- Preferably a verb e.g. get_car(), purchase(), book()
- If the name contains multiple words, it should be separated by underscores (_) e.g. get_json()
- Clear and descriptive method names without abbreviations are preferred.
class Person
def get_height(self)
return self.height
end
end
To make a method private, use the keyword private
above it anywhere in the class.
class Person
def get_height(self)
return self.height
end
private
def get_weight(self)
return self.height
end
end
Above, get_height()
is public, get_weight()
is private. You may use the public
key word below private
, but generally this is not done.