Add compareTo operator for XInt/YInt
See original GitHub issueThere are certain scenarios (like the one described in #59) in which it is handy to do something like this:
if (view1.bottom() < view2.bottom()) view1.bottom() else otherView.top()
Currently XInt
/YInt
lack operator fun compareTo
which prevents the above from compiling.
The workaround could be to use minOf(view1.bottom() - view2.bottom(), 0.ydip) == 0.ydip
but that’s a bit ugly.
Can those be added (I can forge a PR) or do you have something specific in mind why this is not a good idea?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Guide to Implementing the compareTo Method - Baeldung
In this tutorial, we'll explore the Comparable interface and its compareTo method, which enables sorting. We'll look at sorting collections ...
Read more >Java String compareTo() method - javatpoint
It returns a positive number, negative number, or 0. It compares strings on the basis of the Unicode value of each character in...
Read more >String.CompareTo Method (System) - Microsoft Learn
Compares this instance with a specified String object and indicates whether this instance precedes, follows, or appears in the same position in the...
Read more >How to use the Comparable CompareTo on Strings in Java
I get an error the operator is undefined for strings. public int compareTo(Emp i) { if (this.getName() == (( ...
Read more >How to override compareTo method in Java - Example Tutorial
Use relational operator to compare integral numeric value i.e. < or > but use ... Java 8 has added many new methods on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released in 0.1.7
Yep, I’ll post one unless someone beats me to it. I guess it’s nothing complicated along the lines of
etc