Last active
August 29, 2015 14:03
-
-
Save nysalor/9b7d0c15692785166d70 to your computer and use it in GitHub Desktop.
const and class
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
class Foo | |
attr_accessor :me | |
def initialize(arg) | |
@me = arg | |
end | |
end | |
class Bar | |
def execute | |
foo = Foo.new('bar class!') | |
puts foo.me | |
end | |
end | |
class Baz | |
Foo = 'missing!!' | |
def execute | |
foo = Foo.new('baz class!') | |
puts foo.me | |
end | |
end | |
bar = Bar.new | |
bar.execute | |
# => "bar class!" | |
baz = Baz.new | |
baz.execute | |
# => undefined method `new' for "missing!!":String (NoMethodError) | |
# Fooクラスが"missing!!"文字列に置き換えられてしまった |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment