fork download
  1. -- ternary operator and the 'and' and 'or' quirky return:
  2. print(false and 1 or 2) --2
  3. print(true and 1 or 2) --1
  4. print(false and 1) --false determined the result
  5. print(true and 1) --1 determined the result
  6. print(1 or 2) --1 determined the result
  7. print(false or 2) --2 determined the result
  8. print(false or nil) --nil determined the result
  9.  
  10. --tables
  11. local tab1 = {1; 2; 3; 4; 5; 6}
  12. local tab2 = {6, 5, 4, 3, 2, 1}
  13. for i=1, #tab1 do print(tab1[i]) end
  14. for i=1, #tab2 do print(tab2[i]) end
  15.  
Success #stdin #stdout 0.01s 2540KB
stdin
Standard input is empty
stdout
2
1
false
1
1
2
nil
1
2
3
4
5
6
6
5
4
3
2
1