-
-
Save juliengdt/95fd31457c765d5e9535 to your computer and use it in GitHub Desktop.
// 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 { | |
} |
Appreciate this
How would I check if number is > 0 and < 100 (excluding 0 and 100) using this?
@Fengson use 1..<100
Thank you! It saved my time.
how to compare two int are equal or not ...
How would I check if number is > 0 and <= 1 (excluding 0) using this?
if 1...100 ~= number {
}
Also, if you want to check that 100 is not included :
if 0..<100 ~= number {
}
how would i check if a number is between 1 and 12(inclusive)?
How i can check if number from 1 to 4 and else if number from 3 to 0 ?
I can check "Integer" number > 0 and < 100, by 1..<100 ~= number
but how would I check "float" number > 0 and < 1 ? (excluding 0 and 1)
@jmitch22 1...12 ~= number
what about if number is greater than 40 but lesser than 80 ? >=40..<80 did not seem to work
I prefer (40..<80).contains(number)
Thanks!
Thanks
THANKSSS
thanks bro!
Please, how would I check if Int(number) is between -1999 and -1001 ??
thanks!