Skip to content

Instantly share code, notes, and snippets.

@nysalor
Last active August 29, 2015 14:03
Show Gist options
  • Save nysalor/9b7d0c15692785166d70 to your computer and use it in GitHub Desktop.
Save nysalor/9b7d0c15692785166d70 to your computer and use it in GitHub Desktop.
const and class
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