notes

Personal notes
git clone git://git.laack.co/notes.git
Log | Files | Refs

Lua.md (1004B)


      1 # Lua
      2 
      3 **Source:** [https://en.wikipedia.org/wiki/Lua/](https://en.wikipedia.org/wiki/Lua/)
      4 
      5 ## Summary
      6 
      7 Lua is a lightweight embeddable scripting language designed to extend applications by providing a small set of simple primitives and a flexible core that can be easily integrated with existing software systems. 
      8 
      9 ## Strange Characteristics
     10 
     11 Lua doesn't support standard increment / decrement syntax.
     12 
     13 ```lua
     14 index = 0
     15 -- "index += 1" isn't valid
     16 index = index + 1
     17 ```
     18 
     19 Lua does not use conventional syntax for inequality.
     20 
     21 ```lua
     22 if index ~= 10 then
     23     print("index is not 10")
     24 end
     25 ```
     26 
     27 Lua uses 1-based indexing.
     28 
     29 ```lua
     30 arr = {"a", "b", "c"}
     31 print(arr[1]) -- prints "a"
     32 ```
     33 
     34 Every built-in [collection](Collection.md) structure in Lua is a table.
     35 
     36 ```lua
     37 arr = {
     38   [1] = "a",
     39   [2] = "b",
     40   [3] = "c"
     41 } -- explicit statement of an "array" in lua
     42 
     43 arr1= {
     44   [0] = "a",
     45   [1] = "b",
     46   [2] = "c"
     47 } -- this is not how lua saves "arrays", but this is how a zero-indexed array could be represented
     48 ```