Closed pipcet closed 6 years ago
This is a documentation bug. The POD for Mojo::Pg::Results contains these examples:
say $results->arrays->reduce(sub { $a->[3] + $b->[3] });
say $results->hashes->reduce(sub { $a->{money} + $b->{money} });
which fail to work if there are more than two elements in $results. The proper code for the second example would be:
$results
say $results->hashes->reduce(sub { { money => $a->{money} + $b->{money} } })->{money};
Alternatively,
say $results->hashes->reduce(sub { $a + $b->{money} }, 0);
That's even shorter than the original code!
Thanks, you are absolutely correct, that was a typo.
This is a documentation bug. The POD for Mojo::Pg::Results contains these examples:
which fail to work if there are more than two elements in
$results
. The proper code for the second example would be: