我正在阅读一个寻找不同结构的电子表格.当我尝试以下使用Moose时,它似乎做了我想要的.我可以创建不同类型的对象,将其分配给找到的成员
并转储Cell实例以供审核.
并转储Cell实例以供审核.
package Cell { use Moose; use Moose::Util::TypeConstraints; use namespace::autoclean; has 'str_val' => ( is => 'ro',isa => 'Str',required => 1 ); has 'x_id' => ( is => 'ro',); # later required => 1 ); has 'color' => ( is => 'ro',); has 'border' => ( is => 'ro',); has 'found' => ( is => 'rw',isa => 'Sch_Symbol|Chip_Symbol|Net',); 1; }
如果我尝试在Perl 6中执行相同操作,则无法编译.
class Cell { has Str $.str_val is required; has Str $.x_id is required; has Str $.color; has Str $.border; has Sch_Symbol|Chip_Symbol|Net $.found is rw }
06002
我怎样才能在Perl 6中做到这一点?