Skip to content

Instantly share code, notes, and snippets.

@SamGerber-zz
Created December 9, 2015 06:45
Show Gist options
  • Save SamGerber-zz/9bdb9c8d6b7cd0438edc to your computer and use it in GitHub Desktop.
Save SamGerber-zz/9bdb9c8d6b7cd0438edc to your computer and use it in GitHub Desktop.
Setting Instance Variables Using an Attribute Writer
class Universe
attr_writer :answer
end
universe = Universe.new # => #<Universe:0x007f9ac4572e78>
universe.instance_variables # => []
universe.answer = "42" # => "42"
universe.instance_variables # => [:@answer]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment