Created
December 9, 2015 06:45
-
-
Save SamGerber-zz/9bdb9c8d6b7cd0438edc to your computer and use it in GitHub Desktop.
Setting Instance Variables Using an Attribute Writer
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 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