Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你可以做
use Moose::Role; requires 'method';
我在Moose::Spec::Role中看到我也可以要求属性,但我该怎么做呢?
完全相同的语法。Moose 属性提供了一个访问器方法。从实际的CPAN 文档:
“需要(@method_names)角色可以要求某些方法由任何扮演该角色的类实现。
请注意,属性访问器也算作满足角色要求的方法。”