Re: Consider enhancing Comparable with lessThan(), greaterThan() and friends

2022-04-21 Thread Stuart Marks
Yes, this has been proposed before. See https://bugs.openjdk.java.net/browse/JDK-8241056 It's not obviously a bad idea, but there are a bunch of costs that seem to counterbalance the benefits. I think the biggest problem is that adding a bunch of default methods to a widely-implemented

Consider enhancing Comparable with lessThan(), greaterThan() and friends

2022-04-21 Thread Petr Janeček
Hello, I'm pretty sure this must have come up a few times now, but I was unable to find a discussion anywhere, so here goes: The `if (object.compareTo(other) > 0)` construct for Comparables, while it works, is an annoyance to readers, and I often have to do a double-take when seeing it, to make