Attr_accessor:
While initializing object you can assign the value to it. Check the following example and practice it.
- class Person
- attr_accessor :name
- def initialize(name)
- self.name = name
- end
- end
- person = Person.new("Andreas")
- puts person.name
- person.name = "David"
- puts person.name
- Hope you will practice it, i will get back to you with new concept.
Ruby tutorial session 5
Subscribe to:
Posts (Atom)
My Experience in RUBYCONF INDIA 2016
Hi Readers, Rubyconf India is a global event complementing other RubyConf events across the world. I attended this event held on 19-20 ma...
-
Hi Readers, This is the last post for Ruby beginners. Today we are going to learn some small concepts and Ruby load paths and auto ...
-
Hi readers, In this post we are going to learn how to open existing class defination and alias the method which is exist already i...
-
Hi Readers, Today we are going to learn RDoc and Option Parsing, means ruby documentation and their options. In this we are also using ...
No comments:
Post a Comment