在驼鹿中,如何为子类中的超级类指定构造函数?
我有一个带有一些属性的 Moose 类(x
、y
、z
)。我对它进行子类化,对于子类,x
始终为 3。我如何在子类中指定它?
I have a Moose class with some properties (x
,y
,z
). I subclass it, and for the subclass, x
is always 3. How can I specify this in subclass?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个人可以使用
build> buildargs
buildargs 。One could use
BUILDARGS
.我以前和 Moo 一起工作过,但看起来是一样的。您只需使用
+
在子类中声明属性即可覆盖之前的声明。I used to work with Moo but it seems to be the same. You just need to declare the property in the subclass using
+
to override previous declaration.