Sum and product of an array

Using built-in methods:

var ary = [1, 2, 3, 4, 5]
say ary.sum                  # => 15
say ary.prod                 # => 120

Alternatively, using hyper-operators:

var ary = [1, 2, 3, 4, 5]
say ary«+»                   # => 15
say ary«*»                   # => 120

Last updated