Created
December 5, 2019 08:43
-
-
Save michaelevensen/d57f94381b833e13c6fad3cf0c7a7f28 to your computer and use it in GitHub Desktop.
Awesome MinMax function.
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
func ensureRange<T>(value: T, minimum: T, maximum: T) -> T where T : Comparable { | |
return min(max(value, minimum), maximum) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment