Advertisement
Snusmumriken

Simple lua expressions for kiddies

Jun 30th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. --# Simple lua expressions for kiddies
  2.  
  3. -- not equal:
  4.  
  5. a = 10
  6.  
  7. if a == 10 then print('a equals 10!') end --> prints "a equals 10!"
  8.  
  9. if a ~= 10 then print('a doesn\'t equals 10!') end
  10.  
  11. if not (a == 10) then print('a doesn\'t equals 10!') end
  12.  
  13. b = a == 10 --> b == true
  14.  
  15. c = not (a == 10) --> c == false
  16.  
  17. -- logical expressions:
  18.  
  19. print(false and true)  --> false
  20. print(false and true)  --> false
  21. print(false or  true)  --> true
  22. print(true  or  false) --> true
  23.  
  24. print(10 and 'yo') --> 'yo', 10 and 'yo' is "true"
  25. print(10 or  'yo') --> 10
  26.  
  27. print(10 and 20 and 30 and 40) --> 40
  28. print(10 and 20 or  30 and 40) --> 20
  29.  
  30. print(10 and false and 30 and 40) --> false
  31. print(10 and false or  30 and 40) --> 40
  32.  
  33. print(not true) --> false
  34. print(not 'yo') --> false
  35.  
  36. print(not not true) --> true
  37. print(not not 'yo') --> true
  38.  
  39. print(10 and not false and 30 and 40) --> 40
  40. print(10 and not false or  30 and 40) --> true (not false -> true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement