-
-
Save jeffery812/a89a09e567dc24b32907b6dd2b1030ce to your computer and use it in GitHub Desktop.
To check if a number is between a range in Swift
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
// 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