更新时间:2023-09-29 09:46:46
如果使用class Foo::Bar
,但尚未定义Foo
模块,则会引发异常,而module Foo; class Bar
方法将定义Foo
(如果尚未定义的话).
If you use class Foo::Bar
, but the Foo
module hasn't been defined yet, an exception will be raised, whereas the module Foo; class Bar
method will define Foo
if it hasn't been defined yet.
也可以使用块格式在以下范围内定义多个类:
Also, with the block format, you could define multiple classes within:
module Foo
class Bar; end
class Baz; end
end