Skip to content

Commit

Permalink
Simplify sub index candidates
Browse files Browse the repository at this point in the history
Named parameters can be optional and still expected.  This is
different from methods, where unexpected nameds are just ignored.
  • Loading branch information
lizmat committed Feb 13, 2020
1 parent ea44c19 commit 327c74a
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/core.c/Cool.pm6
Expand Up @@ -448,24 +448,16 @@ multi sub flip(Cool $s --> Str:D) { $s.flip }

proto sub index($, $, $?, *%) {*}
multi sub index(Cool:D $s,
Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark) --> Int:D) {
Cool:D $needle, :i(:$ignorecase), :m(:$ignoremark) --> Int:D) {
$s.Str.index($needle.Str, :$ignorecase, :$ignoremark)
}
multi sub index(Cool:D $s, Cool:D $needle, :m(:$ignoremark)! --> Int:D) {
$s.Str.index($needle.Str, :$ignoremark)
}
multi sub index(Cool:D $s, Cool:D $needle --> Int:D) {
$s.Str.index($needle.Str)
}

multi sub index(Cool:D $s,
Cool:D $needle, Cool:D $pos, :i(:$ignorecase)!, :m(:$ignoremark) --> Int:D) {
Cool:D $needle, Cool:D $pos, :i(:$ignorecase), :m(:$ignoremark) --> Int:D) {
$s.Str.index($needle.Str,$pos.Int, :$ignorecase, :$ignoremark)
}
multi sub index(Cool:D $s,
Cool:D $needle, Cool:D $pos, :m(:$ignoremark)! --> Int:D) {
$s.Str.index($needle.Str,$pos.Int, :$ignoremark)
}
multi sub index(Cool:D $s, Cool:D $needle, Cool:D $pos --> Int:D) {
$s.Str.index($needle.Str,$pos.Int)
}
Expand Down

0 comments on commit 327c74a

Please sign in to comment.