You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a sequence contains multiple maximum or minimum elements, the methods max(), max(by:), min(), and min(by:) seem to prefer returning the earlier element, but this isn't documented. I'd like to feel secure in relying on this behavior, so it would be great to have this reflected in the method documentation. Or if the standard library doesn't want to guarantee this then it should explicitly call that out.
The text was updated successfully, but these errors were encountered:
I think it's reasonable to document this for the ones that take a closure. But Equatable.== implies substitutability, so the most conservative position would be to not make that same guarantee for those because it's dubious to be relying on it mattering, so reasonable to reserve the flexibility. That's probably just me being picky though.
I see that argument. I would counter that equatable doesn't mean indistinguishable, and in particular objects will always be distinguishable by object address even if they're equal in all other respects, but I won't be particularly upset if the non-closure variants don't make the guarantee.
Additional Detail from JIRA
md5: e9f6410fc30a27624842e038e73b423c
Issue Description:
When a sequence contains multiple maximum or minimum elements, the methods
max()
,max(by:)
,min()
, andmin(by:)
seem to prefer returning the earlier element, but this isn't documented. I'd like to feel secure in relying on this behavior, so it would be great to have this reflected in the method documentation. Or if the standard library doesn't want to guarantee this then it should explicitly call that out.The text was updated successfully, but these errors were encountered: