Repository navigation
Sum
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Returns the sum of the values in an iterable, optionally summing selected values.
total = values:sum(selector)| Parameter | Type | Description |
|---|---|---|
selector |
function(value, sourceKey) (optional) |
Returns the numeric value to add. |
The numeric total. An empty iterable returns 0.
Without a selector, each value must be numeric. With a selector, each selected result must be numeric.
local totalHealing = LuaQ.from({
{ potion = "Saradomin brew", healing = 900 },
{ potion = "Saradomin brew", healing = 900 },
{ potion = "Shark", healing = 200 },
})
:sum(function(food) return food.healing end)
-- 2000- Home
- Getting Started
-
Functions
- aggregate
- all
- any
- concat
- contains
- count
- create
- createFrom
- deepCopy
- difference
- elementAt
- elementAtOrDefault
- first
- firstOrDefault
- flatMap
- foreach
- groupBy
- groupByResult
- indexOf
- intersect
- ipairs
- last
- lastOrDefault
- map
- max
- min
- pairs
- sequenceEquals
- single
- singleOrDefault
- sort
- sortBy
- sortByDescending
- sortDescending
- sum
- take
- takeWhile
- thenBy
- thenByDecending
- toLookup
- toMap
- toSet
- toTable
- union
- unique
- where
- zip
- Aliases