Jack Not Equal Expression?

classic Classic list List threaded Threaded
2 messages Options
jrd
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Jack Not Equal Expression?

jrd
What is/are the correct operator(s) to represent a "not equal" expression in Jack?

(For example, in other languages, I'm used to writing a != b)

However, in Jack, would this be correct in expressing "a not equals b"?

a ~= b

If not, can you pls clarify?  I don't see the "not equals" expression in the chapter examples.  Thx.

- JRD
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jack Not Equal Expression?

cadet1620
Administrator
There is no "not equals" operator in Jack.

You need to use the unary "not" operator on an "equals" sub-expression:
    if (~(a=b)) {
        // Do something if 'a' does not equal 'b'.
    }

(This is also how you code <= and >=.)

--Mark
Loading...