Created
May 15, 2012 13:47
-
-
Save lolmaus/2701912 to your computer and use it in GitHub Desktop.
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
class MyClass | |
def i_understand_how_this_works(local_var) | |
@the_string ||= "omg" | |
@the_string << local_var | |
end | |
def how_is_that_possible | |
@the_string ||= "omg" | |
end | |
def put | |
puts "> #{@the_string}" | |
end | |
end | |
vasya = MyClass.new | |
vasya.put # > | |
vasya.i_understand_how_this_works " wtf" | |
vasya.put # > omg wtf | |
vasya.how_is_that_possible << " igo" | |
# It modifies an instance var without | |
# either exposing it via attr_writer | |
# or doing an assignment withing the method! | |
vasya.put # > omg wtf igo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment