It looks like maxpairs
doesn't like to be called on a list with undefined values:
> my @foo; @foo[2] = 4; say @foo.maxpairs;
Use of uninitialized value of type Any in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <unknown file> line 1
(2 => 4)
max
doesn't have the same issue and seems to simply ignore undefined values:
> my @foo; @foo[2] = 4; say @foo.max;
4
The same error does occur with:
> my @foo; @foo[2] = 4; say @foo.pairs.max(*.value)
Use of uninitialized value of type Any in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <unknown file> line 1
2 => 4
So it appears that undefined values are only ignored when using max
without a filter parameter.
Is this a bug?
Since this looks like a bug, I've fixed it with
https://github.com/rakudo/rakudo/commit/7bf7a2c6f83a57713c
Which also takes care of "minpairs".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With