Created
June 24, 2015 15:50
-
-
Save nanki/d60c5230844da5a9b633 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# OK | |
class A | |
def a=(a) | |
@a = a | |
end | |
end | |
# OK | |
class B | |
def a=(a);@a = a;end | |
end | |
# NG | |
class C | |
def a | |
@a | |
end | |
def a=(a);@a = a end | |
end | |
# compile error | |
# class D | |
# def a=(a);@a = a end | |
# end | |
[A, B, C].each do |klass| | |
a = klass.new | |
a.a = 2 | |
p a | |
end | |
# $ crystal --version | |
# Crystal 0.7.3 [bf72b07] (Sun Jun 7 16:17:59 UTC 2015) | |
# $ crystal semicolon.cr | |
# #<A:0x10f074ea0 @a=2> | |
# #<B:0x10f074e80 @a=2> | |
# #<C:0x10f078fe0 @a=nil> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment