Skip to content

Instantly share code, notes, and snippets.

@juliengdt
Created August 26, 2015 07:48
Show Gist options
  • Save juliengdt/95fd31457c765d5e9535 to your computer and use it in GitHub Desktop.
Save juliengdt/95fd31457c765d5e9535 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 {
}
@scott-lydon
Copy link

Thanks!

@pkc456
Copy link

pkc456 commented Jun 24, 2020

Thanks

Copy link

ghost commented Nov 7, 2020

THANKSSS

@ramonfsk
Copy link

thanks bro!

@AMBIENTE1
Copy link

Please, how would I check if Int(number) is between -1999 and -1001 ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment