Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhihuitang/a89a09e567dc24b32907b6dd2b1030ce to your computer and use it in GitHub Desktop.
Save zhihuitang/a89a09e567dc24b32907b6dd2b1030ce to your computer and use it in GitHub Desktop.
To check if a number is between a range in Swift
// To check if a number is between a range, don't do
if number >=0 && number <= 100 {
}
// Use range and news operators instead :
if 0...100 ~= number {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment