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

Make Pathname comparable #40

Closed
wants to merge 1 commit into from
Closed

Conversation

gmcgibbon
Copy link

@gmcgibbon gmcgibbon commented Aug 1, 2024

Fixes 20676

I tried comparing pathnames to see if one was a subdirectory of another, and noticed it implements <=> but doesn't include Comparable. This allows pathnames respond to comparison operators and methods like their backing strings do.

Allows Pathname objects to respond to comparison methods like <, >, <=,
>=, between?, and clamp using its implementation of <=>.
@gmcgibbon
Copy link
Author

Looks like <=> doesn't behave the way I thought it did.

Pathname.include Comparable
Pathname("/a/b") <= Pathname("/a/b/c") # is true, but
Pathname("/a/b") <= Pathname("/a/c") # is also true

Closing. Thanks for the feedback on the issue! ❤️

@gmcgibbon gmcgibbon closed this Aug 14, 2024
@gmcgibbon gmcgibbon deleted the comparable branch August 14, 2024 16:39
@Hanmac
Copy link

Hanmac commented Aug 15, 2024

I think Pathname should still implement Comparable when defining the <=> method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants