Getter and Setter Methods
In my previous posts you learn about the class and inheritanceNow we are going to get the information regarding the setter and getter methods of a ruby class
class Person def initialize(name) self.name = name end def name @name end def name=(name) @name = name end end person = Person.new("Andreas") puts person.name person.name = "David" puts person.name
In the above person class name definition is the one contains setter and getter methods.
In next post we will learn what attr_accessor.
Follow my blog to get more updates.
No comments:
Post a Comment