Skip to content

Instantly share code, notes, and snippets.

@SamGerber-zz
Created December 9, 2015 06:52
Show Gist options
  • Save SamGerber-zz/54a157a7fa864812d007 to your computer and use it in GitHub Desktop.
Save SamGerber-zz/54a157a7fa864812d007 to your computer and use it in GitHub Desktop.
Getting Instance Variables Using an Attribute Reader
class Universe
attr_reader :answer
def initialize
@answer = "42"
end
end
universe = Universe.new # => #<Universe:0x007f644d49de10 @answer="42">
universe.answer # => "42"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment