Created
April 3, 2018 05:07
-
-
Save mykiy/c8b995e2abd315cd9c9038fa153d38de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Work | |
| def initialize(name) #when instance object created, the object calls the inititalize method and initiated the valur to instance variables | |
| @name = name | |
| end | |
| def duration=(time) | |
| @duration = time | |
| end | |
| def duration | |
| @duration | |
| end | |
| def name | |
| @name | |
| end | |
| end | |
| job = Work.new("ROR learning") | |
| job.duration = "1month" | |
| job.duration #which returns the value | |
| job.name | |
| job.name ="Ruby" #it will throw a error, there is no setter methods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment