相关疑难解决方法(0)

index()错误消息对第三个参数不正确?

sub count-a {
    my $word = "banana";
    my $count = 0;
    my $foo;      #  Source of error: $foo intentionally not given a value.
                 #  The value ought to be zero.

    while True {
      $foo = index $word, "a", $foo;
      last unless $foo.defined;
      $foo++;
      $count++
  }
  return $count;
}

say count-a;
Run Code Online (Sandbox Code Playgroud)

此错误消息是否有误?

Cannot resolve caller index(Str: Str, Any); none of these signatures match:
  (Str:D $: Cool:D $needle, *%_)
  (Str:D $: Str:D $needle, *%_)
  (Str:D $: Cool:D $needle, Cool:D $pos, *%_)
  (Str:D …
Run Code Online (Sandbox Code Playgroud)

type-conversion signature perl6 error-messaging

6
推荐指数
1
解决办法
108
查看次数