Skip to content

Commit f0e14bf

Browse files
author
Jan-Olof Hendig
committed
Added documentation for method sum
1 parent c7d583d commit f0e14bf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/Type/List.pod

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,25 @@ elements but simply skip any undefined value:
961961
962962
will display the following values: C<1, 1, 1, 2, 2, 3>
963963
964+
=head2 routine sum
965+
966+
Defined as:
967+
968+
multi sub sum($list) returns Numeric:D
969+
multi method sum(List:D:) returns Numeric:D
970+
971+
Usage:
972+
973+
sum LIST
974+
LIST.sum
975+
976+
Returns the sum of all elements in the list or 0 if the list is empty.
977+
Throws an exception if an element can not be coerced into Numeric.
978+
979+
say (1, 3, pi).sum; # 7.14159265358979
980+
say (1, "0xff").sum; # 256
981+
say sum(0b1111, 5); # 20
982+
964983
=end pod
965984

966985
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)