mothy
mothy

Reputation: 147

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
    }

Upvotes: 4

Views: 6909

Answers (2)

Umit Kaya
Umit Kaya

Reputation: 5951

You can use:

if !(int > 1) {
// Do something...
}

Upvotes: 4

ezig
ezig

Reputation: 1229

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."

Upvotes: 12

Related Questions