我有一个有两个多方法(multi submit
)的类。
我这样称呼我的多:
$perspective.submit(:message($message.content));
哪个被运到我的班级:
my $perspective-api = API::Perspective.new(:api-key(%*ENV<PERSPECTIVE_API_KEY>));
proto method submit (|) {*}
multi method submit(Str :$message!, MODEL :@models = TOXICITY) {
my $score = $perspective-api.analyze(:@models, :comment($message));
say @models Z=> $score<attributeScores>{@models}.map: *<summaryScore><value>;
multi method submit(Str :$name!, MODEL :@models = TOXICITY) {
my $score = $perspective-api.analyze(:@models, :comment($name));
say @models Z=> $score<attributeScores>{@models}.map: *<summaryScore><value>;
}
但是我总是得到以下回复:
Died because of the exception:
Cannot resolve caller AUTOGEN(Rose::ContentAnalysis::Perspective:D: :message(Str)); none of these signatures match:
(Rose::ContentAnalysis::Perspective: Str :$message!, MODEL :@models = MODEL::TOXICITY, *%_)
(Rose::ContentAnalysis::Perspective: Str :$name!, MODEL :@models = MODEL::TOXICITY, *%_)
尽管我的命名参数 ( :message
) 是Str
必需的并且@models
声明了默认值。