Operators: Boolean

edit

Boolean Not

edit

Use the boolean not operator '!' to NOT a boolean type value where true is flipped to false and false is flipped to true.

Errors

  • If a value other than a boolean type value or a value that is castable to a boolean type value is given.

Truth

original result

true

false

false

true

Grammar

boolean_not: '!' expression;

Examples

  • Boolean not with the boolean type.

    boolean x = !false; 
    boolean y = !x;     

    declare boolean x; boolean not boolean falseboolean true; store boolean true to x

    declare boolean y; load from xboolean true; boolean not boolean trueboolean false; store boolean false to y

  • Boolean not with the def type.

    def y = true; 
    def z = !y;   

    declare def y; implicit cast boolean true to defdef; store true to y

    declare def z; load from ydef; implicit cast def to boolean true → boolean true; boolean not boolean trueboolean false; implicit cast boolean false to defdef; store def to z

Greater Than

edit

Use the greater than operator '>' to COMPARE two numeric type values where a resultant boolean type value is true if the left-hand side value is greater than to the right-hand side value and false otherwise.

Errors

  • If either the evaluated left-hand side or the evaluated right-hand side is a non-numeric value.

Grammar

greater_than: expression '>' expression;

Promotion

byte

short

char

int

long

float

double

def

byte

int

int

int

int

long

float

double

def

short

int

int

int

int

long

float

double

def

char

int

int

int

int

long

float

double

def

int

int

int

int

int

long

float

double

def

long

long

long

long

long

long

float

double

def

float

float

float

float

float

float

float

double

def

double

double

double

double

double

double

double

double

def

def

def

def

def

def

def

def

def

def

Examples

  • Greater than with different numeric types.

    boolean x = 5 > 4; 
    double y = 6.0;    
    x = 6 > y;         

    declare boolean x; greater than int 5 and int 4boolean true; store boolean true to x;

    declare double y; store double 6.0 to y;

    load from ydouble 6.0 @0; promote int 6 and double 6.0: result double; implicit cast int 6 to double 6.0 @1double 6.0 @1; greater than double 6.0 @1 and double 6.0 @0boolean false; store boolean false to x

  • Greater than with def type.

    int x = 5;       
    def y = 7.0;     
    def z = y > 6.5; 
    def a = x > y;   

    declare int x; store int 5 to x

    declare def y; implicit cast double 7.0 to defdef; store def to y

    declare def z; load from ydef; implicit cast def to double 7.0double 7.0; greater than double 7.0 and double 6.5boolean true; implicit cast boolean true to defdef; store def to z

    declare def a; load from ydef; implicit cast def to double 7.0double 7.0; load from xint 5; promote int 5 and double 7.0: result double; implicit cast int 5 to double 5.0double 5.0; greater than double 5.0 and double 7.0boolean false; implicit cast boolean false to defdef; store def to z

Greater Than Or Equal

edit

Use the greater than or equal operator '>=' to COMPARE two numeric type values where a resultant boolean type value is true if the left-hand side value is greater than or equal to the right-hand side value and false otherwise.

Errors

  • If either the evaluated left-hand side or the evaluated right-hand side is a non-numeric value.

Grammar

greater_than_or_equal: expression '>=' expression;

Promotion

byte

short

char

int

long

float

double

def

byte

int

int

int

int

long

float

double

def

short

int

int

int

int

long

float

double

def

char

int

int

int

int

long

float

double

def

int

int

int

int

int

long

float

double

def

long

long

long

long

long

long

float

double

def

float

float

float

float

float

float

float

double

def

double

double

double

double

double

double

double

double

def

def

def

def

def

def

def

def

def

def

Examples

  • Greater than or equal with different numeric types.

    boolean x = 5 >= 4; 
    double y = 6.0;     
    x = 6 >= y;         

    declare boolean x; greater than or equal int 5 and int 4boolean true; store boolean true to x

    declare double y; store double 6.0 to y

    load from ydouble 6.0 @0; promote int 6 and double 6.0: result double; implicit cast int 6 to double 6.0 @1double 6.0 @1; greater than or equal double 6.0 @1 and double 6.0 @0boolean true; store boolean true to x

  • Greater than or equal with the def type.

    int x = 5;        
    def y = 7.0;      
    def z = y >= 7.0; 
    def a = x >= y;   

    declare int x; store int 5 to x;

    declare def y implicit cast double 7.0 to defdef; store def to y

    declare def z; load from ydef; implicit cast def to double 7.0 @0double 7.0 @0; greater than or equal double 7.0 @0 and double 7.0 @1boolean true; implicit cast boolean true to defdef; store def to z

    declare def a; load from ydef; implicit cast def to double 7.0double 7.0; load from xint 5; promote int 5 and double 7.0: result double; implicit cast int 5 to double 5.0double 5.0; greater than or equal double 5.0 and double 7.0boolean false; implicit cast boolean false to defdef; store def to z

Less Than

edit

Use the less than operator '<' to COMPARE two numeric type values where a resultant boolean type value is true if the left-hand side value is less than to the right-hand side value and false otherwise.

Errors

  • If either the evaluated left-hand side or the evaluated right-hand side is a non-numeric value.

Grammar

less_than: expression '<' expression;

Promotion

byte

short

char

int

long

float

double

def

byte

int

int

int

int

long

float

double

def

short

int

int

int

int

long

float

double

def

char

int

int

int

int

long

float

double

def

int

int

int

int

int

long

float

double

def

long

long

long

long

long

long

float

double

def

float

float

float

float

float

float

float

double

def

double

double

double

double

double

double

double

double

def

def

def

def

def

def

def

def

def

def

Examples

  • Less than with different numeric types.

    boolean x = 5 < 4; 
    double y = 6.0;    
    x = 6 < y;         

    declare boolean x; less than int 5 and int 4boolean false; store boolean false to x

    declare double y; store double 6.0 to y

    load from ydouble 6.0 @0; promote int 6 and double 6.0: result double; implicit cast int 6 to double 6.0 @1double 6.0 @1; less than double 6.0 @1 and double 6.0 @0boolean false; store boolean false to x

  • Less than with the def type.

    int x = 5;       
    def y = 7.0;     
    def z = y < 6.5; 
    def a = x < y;   

    declare int x; store int 5 to x

    declare def y; implicit cast double 7.0 to defdef; store def to y

    declare def z; load from ydef; implicit cast def to double 7.0double 7.0; less than double 7.0 and double 6.5boolean false; implicit cast boolean false to defdef; store def to z

    declare def a; load from ydef; implicit cast def to double 7.0double 7.0; load from xint 5; promote int 5 and double 7.0: result double; implicit cast int 5 to double 5.0double 5.0; less than double 5.0 and double 7.0boolean true; implicit cast boolean true to defdef; store def to z

Less Than Or Equal

edit

Use the less than or equal operator '<=' to COMPARE two numeric type values where a resultant boolean type value is true if the left-hand side value is less than or equal to the right-hand side value and false otherwise.

Errors

  • If either the evaluated left-hand side or the evaluated right-hand side is a non-numeric value.

Grammar

greater_than_or_equal: expression '<=' expression;

Promotion

byte

short

char

int

long

float

double

def

byte

int

int

int

int

long

float

double

def

short

int

int

int

int

long

float

double

def

char

int

int

int

int

long

float

double

def

int

int

int

int

int

long

float

double

def

long

long

long

long

long

long

float

double

def

float

float

float

float

float

float

float

double

def

double

double

double

double

double

double

double

double

def

def

def

def

def

def

def

def

def

def

Examples

  • Less than or equal with different numeric types.

    boolean x = 5 <= 4; 
    double y = 6.0;     
    x = 6 <= y;         

    declare boolean x; less than or equal int 5 and int 4boolean false; store boolean true to x

    declare double y; store double 6.0 to y

    load from ydouble 6.0 @0; promote int 6 and double 6.0: result double; implicit cast int 6 to double 6.0 @1double 6.0 @1; less than or equal double 6.0 @1 and double 6.0 @0boolean true; store boolean true to x

  • Less than or equal with the def type.

    int x = 5;        
    def y = 7.0;      
    def z = y <= 7.0; 
    def a = x <= y;   

    declare int x; store int 5 to x;

    declare def y; implicit cast double 7.0 to defdef; store def to y;

    declare def z; load from ydef; implicit cast def to double 7.0 @0double 7.0 @0; less than or equal double 7.0 @0 and double 7.0 @1boolean true; implicit cast boolean true to defdef; store def to z

    declare def a; load from ydef; implicit cast def to double 7.0double 7.0; load from xint 5; promote int 5 and double 7.0: result double; implicit cast int 5 to double 5.0double 5.0; less than or equal double 5.0 and double 7.0boolean true; implicit cast boolean true to defdef; store def to z

Instanceof

edit

Use the instanceof operator to COMPARE the variable/field type to a specified reference type using the reference type name where a resultant boolean type value is true if the variable/field type is the same as or a descendant of the specified reference type and false otherwise.

Errors

  • If the reference type name doesn’t exist as specified by the right-hand side.

Grammar

instance_of: ID 'instanceof' TYPE;

Examples

  • Instance of with different reference types.

    Map m = new HashMap();            
    boolean a = m instanceof HashMap; 
    boolean b = m instanceof Map;     

    declare Map m; allocate HashMap instance → HashMap reference; implicit cast HashMap reference to Map reference; store Map reference to m

    declare boolean a; load from mMap reference; implicit cast Map reference to HashMap referenceHashMap reference; instanceof HashMap reference and HashMapboolean true; store boolean true to a

    declare boolean b; load from mMap reference; implicit cast Map reference to HashMap referenceHashMap reference; instanceof HashMap reference and Mapboolean true; store true to b; (note HashMap is a descendant of Map)

  • Instance of with the def type.

    def d = new ArrayList();       
    boolean a = d instanceof List; 
    boolean b = d instanceof Map;  

    declare def d; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to defdef; store def to d

    declare boolean a; load from ddef; implicit cast def to ArrayList referenceArrayList reference; instanceof ArrayList reference and Listboolean true; store boolean true to a; (note ArrayList is a descendant of List)

    declare boolean b; load from ddef; implicit cast def to ArrayList referenceArrayList reference; instanceof ArrayList reference and Mapboolean false; store boolean false to a; (note ArrayList is not a descendant of Map)

Equality Equals

edit

Use the equality equals operator '==' to COMPARE two values where a resultant boolean type value is true if the two values are equal and false otherwise. The member method, equals, is implicitly called when the values are reference type values where the first value is the target of the call and the second value is the argument. This operation is null-safe where if both values are null the resultant boolean type value is true, and if only one value is null the resultant boolean type value is false. A valid comparison is between boolean type values, numeric type values, or reference type values.

Errors

  • If a comparison is made between a boolean type value and numeric type value.
  • If a comparison is made between a primitive type value and a reference type value.

Grammar

equality_equals: expression '==' expression;

Promotion

boolean

byte

short

char

int

long

float

double

Reference

def

boolean

boolean

-

-

-

-

-

-

-

-

def

byte

-

int

int

int

int

long

float

double

-

def

short

-

int

int

int

int

long

float

double

-

def

char

-

int

int

int

int

long

float

double

-

def

int

-

int

int

int

int

long

float

double

-

def

long

-

long

long

long

long

long

float

double

-

def

float

-

float

float

float

float

float

float

double

-

def

double

-

double

double

double

double

double

double

double

-

def

Reference

-

-

-

-

-

-

-

-

Object

def

def

def

def

def

def

def

def

def

def

def

def

Examples

  • Equality equals with the boolean type.

    boolean a = true;  
    boolean b = false; 
    a = a == false;    
    b = a == b;        

    declare boolean a; store boolean true to a

    declare boolean b; store boolean false to b

    load from aboolean true; equality equals boolean true and boolean falseboolean false; store boolean false to a

    load from aboolean false @0; load from bboolean false @1; equality equals boolean false @0 and boolean false @1boolean false; store boolean false to b

  • Equality equals with primitive types.

    int a = 1;          
    double b = 2.0;     
    boolean c = a == b; 
    c = 1 == a;         

    declare int a; store int 1 to a

    declare double b; store double 1.0 to b

    declare boolean c; load from aint 1; load from bdouble 2.0; promote int 1 and double 2.0: result double; implicit cast int 1 to double 1.0double `1.0; equality equals double 1.0 and double 2.0boolean false; store boolean false to c

    load from aint 1 @1; equality equals int 1 @0 and int 1 @1boolean true; store boolean true to c

  • Equal equals with reference types.

    List a = new ArrayList(); 
    List b = new ArrayList(); 
    a.add(1);                 
    boolean c = a == b;       
    b.add(1);                 
    c = a == b;               

    declare List a; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to a

    declare List b; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to b

    load from aList reference; call add on List reference with arguments (int 1)

    declare boolean c; load from aList reference @0; load from bList reference @1; call equals on List reference @0 with arguments (List reference @1) → boolean false; store boolean false to c

    load from bList reference; call add on List reference with arguments (int 1)

    load from aList reference @0; load from bList reference @1; call equals on List reference @0 with arguments (List reference @1) → boolean true; store boolean true to c

  • Equality equals with null.

    Object a = null;       
    Object b = null;       
    boolean c = a == null; 
    c = a == b;            
    b = new Object();      
    c = a == b;            

    declare Object a; store null to a

    declare Object b; store null to b

    declare boolean c; load from anull @0; equality equals null @0 and null @1boolean true; store boolean true to c

    load from anull @0; load from bnull @1; equality equals null @0 and null @1boolean true; store boolean true to c

    allocate Object instance → Object reference; store Object reference to b

    load from aObject reference; load from bnull; call equals on Object reference with arguments (null) → boolean false; store boolean false to c

  • Equality equals with the def type.

    def a = 0;               
    def b = 1;               
    boolean c = a == b;      
    def d = new HashMap();   
    def e = new ArrayList(); 
    c = d == e;              

    declare def a; implicit cast int 0 to defdef; store def to a;

    declare def b; implicit cast int 1 to defdef; store def to b;

    declare boolean c; load from adef; implicit cast a to int 0int 0; load from bdef; implicit cast b to int 1int 1; equality equals int 0 and int 1boolean false; store boolean false to c

    declare def d; allocate HashMap instance → HashMap reference; implicit cast HashMap reference to defdef store def to d;

    declare def e; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to defdef store def to d;

    load from ddef; implicit cast def to HashMap referenceHashMap reference; load from edef; implicit cast def to ArrayList referenceArrayList reference; call equals on HashMap reference with arguments (ArrayList reference) → boolean false; store boolean false to c

Equality Not Equals

edit

Use the equality not equals operator '!=' to COMPARE two values where a resultant boolean type value is true if the two values are NOT equal and false otherwise. The member method, equals, is implicitly called when the values are reference type values where the first value is the target of the call and the second value is the argument with the resultant boolean type value flipped. This operation is null-safe where if both values are null the resultant boolean type value is false, and if only one value is null the resultant boolean type value is true. A valid comparison is between boolean type values, numeric type values, or reference type values.

Errors

  • If a comparison is made between a boolean type value and numeric type value.
  • If a comparison is made between a primitive type value and a reference type value.

Grammar

equality_not_equals: expression '!=' expression;

Promotion

boolean

byte

short

char

int

long

float

double

Reference

def

boolean

boolean

-

-

-

-

-

-

-

-

def

byte

-

int

int

int

int

long

float

double

-

def

short

-

int

int

int

int

long

float

double

-

def

char

-

int

int

int

int

long

float

double

-

def

int

-

int

int

int

int

long

float

double

-

def

long

-

long

long

long

long

long

float

double

-

def

float

-

float

float

float

float

float

float

double

-

def

double

-

double

double

double

double

double

double

double

-

def

Reference

-

-

-

-

-

-

-

-

Object

def

def

def

def

def

def

def

def

def

def

def

def

Examples

  • Equality not equals with the boolean type.

    boolean a = true;  
    boolean b = false; 
    a = a != false;    
    b = a != b;        

    declare boolean a; store boolean true to a

    declare boolean b; store boolean false to b

    load from aboolean true; equality not equals boolean true and boolean falseboolean true; store boolean true to a

    load from aboolean true; load from bboolean false; equality not equals boolean true and boolean falseboolean true; store boolean true to b

  • Equality not equals with primitive types.

    int a = 1;          
    double b = 2.0;     
    boolean c = a != b; 
    c = 1 != a;         

    declare int a; store int 1 to a

    declare double b; store double 1.0 to b

    declare boolean c; load from aint 1; load from bdouble 2.0; promote int 1 and double 2.0: result double; implicit cast int 1 to double 1.0double `1.0; equality not equals double 1.0 and double 2.0boolean true; store boolean true to c

    load from aint 1 @1; equality not equals int 1 @0 and int 1 @1boolean false; store boolean false to c

  • Equality not equals with reference types.

    List a = new ArrayList(); 
    List b = new ArrayList(); 
    a.add(1);                 
    boolean c = a == b;       
    b.add(1);                 
    c = a == b;               

    declare List a; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to a

    declare List b; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to b

    load from aList reference; call add on List reference with arguments (int 1)

    declare boolean c; load from aList reference @0; load from bList reference @1; call equals on List reference @0 with arguments (List reference @1) → boolean false; boolean not boolean falseboolean true store boolean true to c

    load from bList reference; call add on List reference with arguments (int 1)

    load from aList reference @0; load from bList reference @1; call equals on List reference @0 with arguments (List reference @1) → boolean true; boolean not boolean trueboolean false; store boolean false to c

  • Equality not equals with null.

    Object a = null;       
    Object b = null;       
    boolean c = a == null; 
    c = a == b;            
    b = new Object();      
    c = a == b;            

    declare Object a; store null to a

    declare Object b; store null to b

    declare boolean c; load from anull @0; equality not equals null @0 and null @1boolean false; store boolean false to c

    load from anull @0; load from bnull @1; equality not equals null @0 and null @1boolean false; store boolean false to c

    allocate Object instance → Object reference; store Object reference to b

    load from aObject reference; load from bnull; call equals on Object reference with arguments (null) → boolean false; boolean not boolean falseboolean true; store boolean true to c

  • Equality not equals with the def type.

    def a = 0;               
    def b = 1;               
    boolean c = a == b;      
    def d = new HashMap();   
    def e = new ArrayList(); 
    c = d == e;              

    declare def a; implicit cast int 0 to defdef; store def to a;

    declare def b; implicit cast int 1 to defdef; store def to b;

    declare boolean c; load from adef; implicit cast a to int 0int 0; load from bdef; implicit cast b to int 1int 1; equality equals int 0 and int 1boolean false; store boolean false to c

    declare def d; allocate HashMap instance → HashMap reference; implicit cast HashMap reference to defdef store def to d;

    declare def e; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to defdef store def to d;

    load from ddef; implicit cast def to HashMap referenceHashMap reference; load from edef; implicit cast def to ArrayList referenceArrayList reference; call equals on HashMap reference with arguments (ArrayList reference) → boolean false; store boolean false to c

Identity Equals

edit

Use the identity equals operator '===' to COMPARE two values where a resultant boolean type value is true if the two values are equal and false otherwise. A reference type value is equal to another reference type value if both values refer to same instance on the heap or if both values are null. A valid comparison is between boolean type values, numeric type values, or reference type values.

Errors

  • If a comparison is made between a boolean type value and numeric type value.
  • If a comparison is made between a primitive type value and a reference type value.

Grammar

identity_equals: expression '===' expression;

Promotion

boolean

byte

short

char

int

long

float

double

Reference

def

boolean

boolean

-

-

-

-

-

-

-

-

def

byte

-

int

int

int

int

long

float

double

-

def

short

-

int

int

int

int

long

float

double

-

def

char

-

int

int

int

int

long

float

double

-

def

int

-

int

int

int

int

long

float

double

-

def

long

-

long

long

long

long

long

float

double

-

def

float

-

float

float

float

float

float

float

double

-

def

double

-

double

double

double

double

double

double

double

-

def

Reference

-

-

-

-

-

-

-

-

Object

def

def

def

def

def

def

def

def

def

def

def

def

Examples

  • Identity equals with reference types.

    List a = new ArrayList(); 
    List b = new ArrayList(); 
    List c = a;               
    boolean c = a === b;      
    c = a === c;              

    declare List a; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to a

    declare List b; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to b

    load from aList reference; store List reference to c

    declare boolean c; load from aList reference @0; load from bList reference @1; identity equals List reference @0 and List reference @1boolean false store boolean false to c

    load from aList reference @0; load from cList reference @1; identity equals List reference @0 and List reference @1boolean true store boolean true to c (note List reference @0 and List reference @1 refer to the same instance)

  • Identity equals with null.

    Object a = null;        
    Object b = null;        
    boolean c = a === null; 
    c = a === b;            
    b = new Object();       
    c = a === b;            

    declare Object a; store null to a

    declare Object b; store null to b

    declare boolean c; load from anull @0; identity equals null @0 and null @1boolean true; store boolean true to c

    load from anull @0; load from bnull @1; identity equals null @0 and null @1boolean true; store boolean true to c

    allocate Object instance → Object reference; store Object reference to b

    load from aObject reference; load from bnull; identity equals Object reference and nullboolean false; store boolean false to c

  • Identity equals with the def type.

    def a = new HashMap();   
    def b = new ArrayList(); 
    boolean c = a === b;     
    b = a;                   
    c = a === b;             

    declare def d; allocate HashMap instance → HashMap reference; implicit cast HashMap reference to defdef store def to d

    declare def e; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to defdef store def to d

    declare boolean c; load from adef; implicit cast def to HashMap referenceHashMap reference; load from bdef; implicit cast def to ArrayList referenceArrayList reference; identity equals HashMap reference and ArrayList referenceboolean false; store boolean false to c

    load from adef; store def to b

    load from adef; implicit cast def to HashMap reference @0HashMap reference @0; load from bdef; implicit cast def to HashMap reference @1HashMap reference @1; identity equals HashMap reference @0 and HashMap reference @1boolean true; store boolean true to b; (note HashMap reference @0 and HashMap reference @1 refer to the same instance)

Identity Not Equals

edit

Use the identity not equals operator '!==' to COMPARE two values where a resultant boolean type value is true if the two values are NOT equal and false otherwise. A reference type value is not equal to another reference type value if both values refer to different instances on the heap or if one value is null and the other is not. A valid comparison is between boolean type values, numeric type values, or reference type values.

Errors

  • If a comparison is made between a boolean type value and numeric type value.
  • If a comparison is made between a primitive type value and a reference type value.

Grammar

identity_not_equals: expression '!==' expression;

Promotion

boolean

byte

short

char

int

long

float

double

Reference

def

boolean

boolean

-

-

-

-

-

-

-

-

def

byte

-

int

int

int

int

long

float

double

-

def

short

-

int

int

int

int

long

float

double

-

def

char

-

int

int

int

int

long

float

double

-

def

int

-

int

int

int

int

long

float

double

-

def

long

-

long

long

long

long

long

float

double

-

def

float

-

float

float

float

float

float

float

double

-

def

double

-

double

double

double

double

double

double

double

-

def

Reference

-

-

-

-

-

-

-

-

Object

def

def

def

def

def

def

def

def

def

def

def

def

Examples

  • Identity not equals with reference type values.

    List a = new ArrayList(); 
    List b = new ArrayList(); 
    List c = a;               
    boolean c = a !== b;      
    c = a !== c;              

    declare List a; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to a

    declare List b; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to List referenceList reference; store List reference to b

    load from aList reference; store List reference to c

    declare boolean c; load from aList reference @0; load from bList reference @1; identity not equals List reference @0 and List reference @1boolean true store boolean true to c

    load from aList reference @0; load from cList reference @1; identity not equals List reference @0 and List reference @1boolean false store boolean false to c (note List reference @0 and List reference @1 refer to the same instance)

  • Identity not equals with null.

    Object a = null;        
    Object b = null;        
    boolean c = a !== null; 
    c = a !== b;            
    b = new Object();       
    c = a !== b;            

    declare Object a; store null to a

    declare Object b; store null to b

    declare boolean c; load from anull @0; identity not equals null @0 and null @1boolean false; store boolean false to c

    load from anull @0; load from bnull @1; identity not equals null @0 and null @1boolean false; store boolean false to c

    allocate Object instance → Object reference; store Object reference to b

    load from aObject reference; load from bnull; identity not equals Object reference and nullboolean true; store boolean true to c

  • Identity not equals with the def type.

    def a = new HashMap();   
    def b = new ArrayList(); 
    boolean c = a !== b;     
    b = a;                   
    c = a !== b;             

    declare def d; allocate HashMap instance → HashMap reference; implicit cast HashMap reference to defdef store def to d

    declare def e; allocate ArrayList instance → ArrayList reference; implicit cast ArrayList reference to defdef store def to d

    declare boolean c; load from adef; implicit cast def to HashMap referenceHashMap reference; load from bdef; implicit cast def to ArrayList referenceArrayList reference; identity not equals HashMap reference and ArrayList referenceboolean true; store boolean true to c

    load from adef; store def to b

    load from adef; implicit cast def to HashMap reference @0HashMap reference @0; load from bdef; implicit cast def to HashMap reference @1HashMap reference @1; identity not equals HashMap reference @0 and HashMap reference @1boolean false; store boolean false to b; (note HashMap reference @0 and HashMap reference @1 refer to the same instance)

Boolean Xor

edit

Use the boolean xor operator '^' to XOR together two boolean type values where if one boolean type value is true and the other is false the resultant boolean type value is true and false otherwise.

Errors

  • If either evaluated value is a value other than a boolean type value or a value that is castable to a boolean type value.

Truth

true

false

true

false

true

false

true

false

Grammar

boolean_xor: expression '^' expression;

Examples

  • Boolean xor with the boolean type.

    boolean x = false;    
    boolean y = x ^ true; 
    y = y ^ x;            

    declare boolean x; store boolean false to x

    declare boolean y; load from xboolean false boolean xor boolean false and boolean trueboolean true; store boolean true to y

    load from yboolean true @0; load from xboolean true @1; boolean xor boolean true @0 and boolean true @1boolean false; store boolean false to y

  • Boolean xor with the def type.

    def x = false;    
    def y = x ^ true; 
    y = y ^ x;        

    declare def x; implicit cast boolean false to defdef; store def to x

    declare def y; load from xdef; implicit cast def to boolean falseboolean false; boolean xor boolean false and boolean trueboolean true; implicit cast boolean true to defdef; store def to y

    load from ydef; implicit cast def to boolean true @0boolean true @0; load from xdef; implicit cast def to boolean true @1boolean true @1; boolean xor boolean true @0 and boolean true @1boolean false; implicit cast boolean falsedef; store def to y

Boolean And

edit

Use the boolean and operator '&&' to AND together two boolean type values where if both boolean type values are true the resultant boolean type value is true and false otherwise.

Errors

  • If either evaluated value is a value other than a boolean type value or a value that is castable to a boolean type value.

Truth

true

false

true

true

false

false

false

false

Grammar

boolean_and: expression '&&' expression;

Examples

  • Boolean and with the boolean type.

    boolean x = true;      
    boolean y = x && true; 
    x = false;             
    y = y && x;            

    declare boolean x; store boolean true to x

    declare boolean y; load from xboolean true @0; boolean and boolean true @0 and boolean true @1boolean true; store boolean true to y

    store boolean false to x

    load from yboolean true; load from xboolean false; boolean and boolean true and boolean falseboolean false; store boolean false to y

  • Boolean and with the def type.

    def x = true;      
    def y = x && true; 
    x = false;         
    y = y && x;        

    declare def x; implicit cast boolean true to defdef; store def to x

    declare def y; load from xdef; implicit cast def to boolean true @0boolean true @0; boolean and boolean true @0 and boolean true @1boolean true; implicit cast boolean true to defdef; store def to y

    implicit cast boolean false to defdef; store def to x;

    load from ydef; implicit cast def to boolean trueboolean true; load from xdef; implicit cast def to boolean falseboolean false; boolean and boolean true and boolean falseboolean false; implicit cast boolean falsedef; store def to y

Boolean Or

edit

Use the boolean or operator '||' to OR together two boolean type values where if either one of the boolean type values is true the resultant boolean type value is true and false otherwise.

Errors

  • If either evaluated value is a value other than a boolean type value or a value that is castable to a boolean type value.

Truth

true

false

true

true

true

false

true

false

Grammar:

boolean_and: expression '||' expression;

Examples

  • Boolean or with the boolean type.

    boolean x = false;     
    boolean y = x || true; 
    y = false;             
    y = y || x;            

    declare boolean x; store boolean false to x

    declare boolean y; load from xboolean false; boolean or boolean false and boolean trueboolean true; store boolean true to y

    store boolean false to y

    load from yboolean false @0; load from xboolean false @1; boolean or boolean false @0 and boolean false @1boolean false; store boolean false to y

  • Boolean or with the def type.

    def x = false;     
    def y = x || true; 
    y = false;         
    y = y || x;        

    declare def x; implicit cast boolean false to defdef; store def to x

    declare def y; load from xdef; implicit cast def to boolean falseboolean true; boolean or boolean false and boolean trueboolean true; implicit cast boolean true to defdef; store def to y

    implicit cast boolean false to defdef; store def to y;

    load from ydef; implicit cast def to boolean false @0boolean false @0; load from xdef; implicit cast def to boolean false @1boolean false @1; boolean or boolean false @0 and boolean false @1boolean false; implicit cast boolean falsedef; store def to y