Mega Code Archive

 
Categories / Ruby / Class
 

Getter and setter

# The setter method name= follows a Ruby convention: the name of the method ends with an equals sign (=).  class Horse   def name     @name   end   def name=( value )     @name = value   end end h = Horse.new h.name= "Poco Bueno" h.name # => "Poco Bueno"