Skip to content

Decimal.sum to support no arguments #207

@yassh

Description

@yassh

Currently, an error occurs when zero arguments is passed to Decimal.sum.

const decimals = []
Decimal.sum(...decimals) // Error occurs

Lodash's _.sum and Ramda's R.sum returns 0 when passed an array with zero elements.

const numbers = []
_.sum(numbers) // => 0
R.sum(numbers) // => 0

Similarly, it would be nice if Decimal.sum returned new Decimal(0) when called with zero arguments.

const decimals = []
Decimal.sum(...decimals) // => new Decimal(0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions