BigDecimal.nonzero? does not return a boolean
ryanseys opened this issue · 2 comments
ryanseys commented
Considering the method ends in a ?
I would assume that by Ruby conventions this should return a Boolean, however it doesn't.
[5] pry(main)> BigDecimal(1).nonzero?
=> 0.1e1
[6] pry(main)> BigDecimal(0).nonzero?
=> nil
In comparison with zero?
:
[7] pry(main)> BigDecimal(0).zero?
=> true
[8] pry(main)> BigDecimal(1).zero?
=> false
If this seems like a reasonable change to have nonzero?
return a boolean instead, I can go ahead and update this code and send a PR :)
mrkn commented
This is the intentionally designed specification of Numeric#nonzero?
.
See https://docs.ruby-lang.org/en/3.0.0/Numeric.html#method-i-nonzero-3F
ryanseys commented
Thanks for the context! I leave even more confused than when I started 😄