Created
August 26, 2015 07:48
-
-
Save juliengdt/95fd31457c765d5e9535 to your computer and use it in GitHub Desktop.
To check if a number is between a range in Swift
This file contains 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
Please, how would I check if Int(number) is between -1999 and -1001 ??