【发布时间】:2018-10-31 22:44:28
【问题描述】:
假设有 A::Very::Shallow::ClassA 和 A::Very::Deep::ClassB
文件:./A/Very/Shallow/ClassA.pm6
class A::Very::Shallow::ClassA{
has Str $.label is rw;
has Str $.icon is rw;
has @.items is rw;
}
我想在 ClassB 中继承 ClassA 所以我写:
文件:./A/Very/Deep/ClassB.pm6
class A::Very::Deep::ClassB is A::Very::Shallow::ClassA{
...
}
但是错误是:
Cannot resolve caller trait_mod:<is>(A::Very::Deep::ClassB, A::Very::Shallow::ClassA, Hash); none of these signatures match:
(Mu:U $child, Mu:U $parent)
(Mu:U $child, :$DEPRECATED!)
(Mu:U $type, :$rw!)
(Mu:U $type, :$nativesize!)
(Mu:U $type, :$ctype!)
(Mu:U $type, :$unsigned!)
(Mu:U $type, :$hidden!)
(Mu:U $type, Mu :$array_type!)
(Mu:U $type, *%fail)
(Attribute:D $attr, |c is raw)
(Attribute:D $attr, :$rw!)
(Attribute:D $attr, :$readonly!)
(Attribute $attr, :$required!)
(Attribute $attr, Mu :$default!)
(Attribute:D $attr, :$box_target!)
...
我找到了大量关于继承的文档和示例,但似乎没有一个涵盖我认为简单的基本问题。我知道答案可能很明显,但我现在想念它。
当类与在同一个包中时会发生什么
A::Money::Card is A::Money::Item
我现在有点困惑,所以任何指针都会很棒。提前谢谢你。
【问题讨论】:
标签: class inheritance raku