Created
January 8, 2012 21:20
-
-
Save danbernier/1579738 to your computer and use it in GitHub Desktop.
Ruby lets you add instance variables at runtime
This file contains 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
ruby-1.9.2-p290 :001 > class Foo | |
ruby-1.9.2-p290 :002?> def bonk | |
ruby-1.9.2-p290 :003?> @bonk = nil | |
ruby-1.9.2-p290 :004?> end | |
ruby-1.9.2-p290 :005?> end | |
=> nil | |
ruby-1.9.2-p290 :006 > f = Foo.new | |
=> #<Foo:0x007ff15c1e65b8> | |
ruby-1.9.2-p290 :007 > f.bonk | |
=> nil | |
ruby-1.9.2-p290 :008 > f.inspect | |
=> "#<Foo:0x007ff15c1e65b8 @bonk=nil>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment