Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compareTo operator for XInt/YInt #63

Closed
dimsuz opened this issue May 13, 2020 · 5 comments · Fixed by #64
Closed

Add compareTo operator for XInt/YInt #63

dimsuz opened this issue May 13, 2020 · 5 comments · Fixed by #64
Labels
good first issue Good for newcomers

Comments

@dimsuz
Copy link

dimsuz commented May 13, 2020

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?

@carranca
Copy link
Collaborator

That feels like an omission - seems like it'd be a good addition (for XInt/YInt/XFloat/YFloat)

@carranca
Copy link
Collaborator

@dimsuz a PR would definitely be welcome, otherwise I or someone else might try to get to it over the next week or two?

@oldergod oldergod reopened this May 14, 2020
@carranca carranca added the good first issue Good for newcomers label May 14, 2020
@dimsuz
Copy link
Author

dimsuz commented 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

@oldergod
Copy link
Collaborator

I will do it right now

@oldergod
Copy link
Collaborator

Released in 0.1.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants