Skip to content

Instantly share code, notes, and snippets.

@mykiy
Last active April 3, 2018 04:46
Show Gist options
  • Select an option

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

Select an option

Save mykiy/3e18fc42ba6ef0ccc7eba66084730ed5 to your computer and use it in GitHub Desktop.
class Work
def name=(name) #which works like a setter method of class
@name = name
end
def name #which works like a gettter method, gets the name from current object scope
@name
end
end
job = Work.new #which creates the new instance object
job.name = "Ruby learning" #which sets the name
job.name #Which returns the name the instance variable holds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment