我在使用模块Function::Parameters时遇到问题Types::Standard。在此代码中,在 Person.pm 中:
package Person;
use strict;
use warnings;
use Function::Parameters;
use Types::Standard qw(InstanceOf);
method is_taller_than(
InstanceOf['Person'] $other
) {
return;
}
1;
Run Code Online (Sandbox Code Playgroud)
使用perl -cw Person.pm报告:
In method is_taller_than: missing type name after '[' at Person.pm line 9.
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
这看起来像是Function::Parameters. 它可以处理裸字和方括号,但不能处理带引号的字符串。解决这个问题的方法就是在类型表达式周围加上括号:
method is_taller_than(
(InstanceOf['Person']) $other
) {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
127 次 |
| 最近记录: |