Last active
March 9, 2022 04:32
-
-
Save cscorley/6ce32318be655f691bed2ebe5242cbb2 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 Test | |
def thing | |
@thing ||= "Hi" | |
end | |
def thing=(new_thing) | |
@thing = new_thing | |
end | |
def do_stuff | |
puts thing | |
if false | |
thing = "Huh!" | |
end | |
puts thing || "Why nil?" | |
end | |
end | |
t = Test.new | |
t.do_stuff |
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 Test | |
attr_accessor :thing | |
def do_stuff | |
puts thing | |
if false | |
thing = "Huh!" | |
end | |
puts thing || "Why nil?" | |
end | |
end | |
t = Test.new | |
t.thing = "hi" | |
t.do_stuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment