May 2017
Intermediate to advanced
416 pages
21h 33m
English
The following are the relational methamethods available:
|
__eq |
Equality |
|
__lt |
Less than |
|
__le |
Less than or equal to |
The function setmetatable is used to set the metastable of a table:
local vuln1 = {criticity_level = 10, name="Vuln #1"} local vuln2= {criticity_level = 4, name="Vuln #2"} local mt = { __add = function (l1, l2) –Override the function “add” return { criticity_level = l1.criticity_level + l2.criticity_level } end } setmetatable(vuln1, mt) setmetatable(vuln2, mt) local total = vuln1 + vuln2 print(total.criticity_level) --Prints 14 when normally it would fail before reaching this statement.
Read now
Unlock full access