Last active
November 21, 2017 10:33
-
-
Save vireshas/138a4c9b92aaa877f615fa3193e70578 to your computer and use it in GitHub Desktop.
@ and self
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
#colleague asks | |
class A | |
attr_accessor :b,:d | |
def a | |
self.b = 10 | |
@d = 20 | |
end | |
def p | |
puts self.b | |
puts @b | |
puts self.d | |
end | |
end | |
a = A.new | |
a.a | |
a.p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment