Created
April 21, 2021 01:46
-
-
Save oieioi/e5a2e9d55eaa307a3c0f41a9f4aee1b6 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 Klass | |
CONST_1 = 1 | |
class << self | |
CONST_2 = 2 | |
def klass_method | |
# ok | |
puts CONST_1 | |
# ok | |
puts CONST_2 | |
end | |
end | |
def instance_method | |
# ok | |
puts CONST_1 | |
# だめ | |
puts CONST_2 | |
rescue => e | |
pp e | |
end | |
end | |
Klass.klass_method | |
Klass.new.instance_method | |
# ok | |
puts Klass::CONST_1 | |
begin | |
# だめ | |
puts Klass::CONST_2 | |
rescue => e | |
pp e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment