Skip to content

Instantly share code, notes, and snippets.

@mykiy
Created April 3, 2018 05:07
Show Gist options
  • Select an option

  • Save mykiy/c8b995e2abd315cd9c9038fa153d38de to your computer and use it in GitHub Desktop.

Select an option

Save mykiy/c8b995e2abd315cd9c9038fa153d38de to your computer and use it in GitHub Desktop.
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