0
我想要阅读的Ruby文档为new
方法,如:Ruby的`BasicObject.new`没有文档吗?
class Dog
end
fido = Dog.new("Fido")
但是通过Ruby的文档跟踪使我this:
new()
不记录
我看错了地方,或者是实际上没有记录的最普遍的方法之一?
我想要阅读的Ruby文档为new
方法,如:Ruby的`BasicObject.new`没有文档吗?
class Dog
end
fido = Dog.new("Fido")
但是通过Ruby的文档跟踪使我this:
new()
不记录
我看错了地方,或者是实际上没有记录的最普遍的方法之一?
看着Dog.new("Fido")
,我相信你正在寻找Class#new
,而不是BasicObject#new
。因为你的Dog
类是Class
的一个实例。
class Dog
#code
end
Dog.instance_of? Class # => true
更多的例子:
Foo = Class.new # Class::new is called
Foo.instance_of? Class # => true
foo = Foo.new # Class#new is called
foo.instance_of? Foo # => true
你链接到'类:: new' – Stefan
@Stefan谢谢指正.. –