sum method

num sum()
  • return list summation ! throws StateError if isEmpty

Implementation

num sum() => sumOrNull() ?? (throw StateError('list is empty'));