Advertisement
Guest User

Untitled

a guest
Dec 5th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var x = null;
  2.         var y = 0;
  3.        
  4.         System.println("x = null");
  5.         System.println("y = 0");
  6.         System.println("");
  7.        
  8.         System.println("Trying if (x)...");
  9.         if (x)
  10.         {
  11.             // do nothing  
  12.         }
  13.         else
  14.         {
  15.             System.println("  if (x) works");
  16.         }
  17.        
  18.         System.println("Trying if (y)...");
  19.         if (y)
  20.         {
  21.             // do nothing  
  22.         }
  23.         else
  24.         {
  25.             System.println("  if (y) works");
  26.         }
  27.        
  28.         System.println("Trying if (x && y)...");
  29.         if (x && y) // this is fine
  30.         {
  31.             // do nothing  
  32.         }
  33.         else
  34.         {
  35.             System.println("  if (x && y) works");
  36.         }
  37.        
  38.         System.println("Trying if (x || y)...");
  39.         if (x || y) // this will crash, probably because logical "||" is misimplemented as bitwise "|"
  40.         {
  41.             // do nothing  
  42.         }
  43.         else
  44.         {
  45.             System.println("if (x || y) works");
  46.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement