question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add compareTo operator for XInt/YInt

See original GitHub issue

There 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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
oldergodcommented, May 19, 2020

Released in 0.1.7

1reaction
dimsuzcommented, May 14, 2020

Yep, I’ll post one unless someone beats me to it. I guess it’s nothing complicated along the lines of

operator fun compareTo(other: XInt): Int {
  return this.value.compareTo(other.value)
}

etc

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found