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

Proposal for tuple comparison operators #45

Merged
merged 1 commit into from Dec 18, 2015

Conversation

lilyball
Copy link
Collaborator

Implement comparison operators on tuples up to some arity.

Previous swift-evolution mailing list discussion: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/000892.html

@lilyball
Copy link
Collaborator Author

Implementation submitted as apple/swift#408.

if lhs.0 != rhs.0 { return lhs.0 < rhs.0 }
if lhs.1 != rhs.1 { return lhs.1 < rhs.1 }
return lhs.2 < rhs.2
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads from left-to-right? Like how version numbers work? But doesn’t that tie to a western way of reading? < has subtleties that == doesn’t I think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it reads from first-to-last. Even if you write in an RTL language, (Int, Double) still has .0 be the Int and .1 be the Double. And this even matches String behavior; the first character in a String is still the first character in a String regardless of whether the character belongs to an LTR or RTL language; the RTL nature of the language only affects how it's displayed on screen. Presumably if you used a Tuple to represent some data that gets displayed on screen, in an RTL locale you'd display the .0 element on the right and the .1 element on the left.

DougGregor added a commit that referenced this pull request Dec 18, 2015
Proposal for tuple comparison operators
@DougGregor DougGregor merged commit 7773ab4 into apple:master Dec 18, 2015
@lilyball lilyball deleted the tuple-comparison-ops branch December 28, 2015 06:47
ktoso pushed a commit to ktoso/swift-evolution that referenced this pull request Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants