Since recently, (I think it's since I converted my code to kotlin but not sure), Android Studio show me a warning when I write
if (myValue.compareTo(BigDecimal.ZERO) > 0)
The message say "Call replaceable with binary operator" and replace my code with
if (myValue > BigDecimal.ZERO)
I noticed I also use
if (myValue.compareTo(BigDecimal.ZERO) == 0
But this time I got no warning and if I try to replace it, it doesn't work
if (myValue == BigDecimal.ZERO) // DOES NOT WORK
Why does > ZERO
work but not == ZERO
? Why every thread that I saw on stackoverflow (for example this) recommand using compareTo
but > ZERO
work and is recommended by Android Studio?