B
Brandon Dimcheff
I'm playing around with classes and discovered that
class Foo
...
end
and
Foo = Class.new do
...
end
seem to behave slightly differently. I assumed that "class Foo" was
just a shortcut that got translated into "Foo = Class.new", but when I
muck with class in the following way:
class Class
class << self
def new
puts "new called"
super
end
end
end
and then do "Foo = Class.new", I get "new called" printed to stdout.
If I do "class Foo..." I get nothing. So it seems that the "class"
keyword does not end up calling new on Class when you define a new
class. Does anybody know what's going on here? Is something else
called instead?
Thanks,
Brandon
class Foo
...
end
and
Foo = Class.new do
...
end
seem to behave slightly differently. I assumed that "class Foo" was
just a shortcut that got translated into "Foo = Class.new", but when I
muck with class in the following way:
class Class
class << self
def new
puts "new called"
super
end
end
end
and then do "Foo = Class.new", I get "new called" printed to stdout.
If I do "class Foo..." I get nothing. So it seems that the "class"
keyword does not end up calling new on Class when you define a new
class. Does anybody know what's going on here? Is something else
called instead?
Thanks,
Brandon