It’s easy enough to create:
object zero extends BigDecimal(java.math.BigDecimal.ZERO)
I’m just wondering whether this was an oversight, or if there was a conscious decision to not add this and, if so, are there reasons why I should avoid the code above. Perhaps having to do with the MathContext?
I’d think it’s because usually you don’t need it. Whereas in Java you need to type something like
in Scala, there are number conversions that mean you can write
You can also write it simply as
BigDecimal(0). If you’re instantiating that a lot you might want to cache it as a named value (as for any other number), but you won’t normally need to, and I think it helps simplify the API if you remove special cases that you have to remember.