- 
                Notifications
    
You must be signed in to change notification settings  - Fork 162
 
Open
Description
There are several methods to compare two Money object but there is no Money.Compare(Money) function.
The proposal is to add a Compare function for Money.
// Compare returns an integer comparing two Money objects
// If Money objects are of different currency, an ErrCurrencyMismatch is returned.
// If both objects are for same currency, their amounts are compared.
// The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
func (m *Money) Compare(om *Money) int {
    if err := m.assertSameCurrency(om); err != nil {
        return false, err
    }
    return m.compare(om), nil
}I'll provide a PR.
totemcaf and syafiqrokman-coinhako
Metadata
Metadata
Assignees
Labels
No labels