Created
March 25, 2025 12:45
-
-
Save hhhello0507/93fff227a051286447e47505a1581e57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Comparable { | |
func clamped(to limits: ClosedRange<Self>) -> Self { | |
return min(max(self, limits.lowerBound), limits.upperBound) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment