Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not Greater Than Operator in Swift !>

All my searches keep turning up irrelevant answers so I was wondering what is the fundamental problem with the question I am asking:

What is the operator in swift that means NOT Greater than " !> " ? Why doesn't this symbol exist?

edit: Just to clarify: I was trying to make an if statement in Swift where, if the value is not greater than or equal to 0, the value is obviously invalid, but I didn't want to specify a number range. I realized that else would probably catch what I was looking for:

if int >= 1 {
        //do something
    }else {
        //number is not an integer greater than 1
        //do something else
    }
like image 292
mothy Avatar asked Dec 06 '22 20:12

mothy


2 Answers

How about <=? If x is not greater than y, then x <= y. There's no need for a "not greater than" operator when it has the same meaning as "less than or equal to."

like image 126
ezig Avatar answered Dec 11 '22 08:12

ezig


You can use:

if !(int > 1) {
// Do something...
}
like image 39
Umit Kaya Avatar answered Dec 11 '22 10:12

Umit Kaya