3 ms·
Lua is another one. The following expressions are all equivalent: object:method(arguments...) object.method(object, arguments...) object["method"](object
by nybble41 6y ago
Lua is another one. The following expressions are all equivalent:
object:method(arguments...)
object.method(object, arguments...)
object["method"](object, arguments...)
Lua objects are tables (associative arrays), the dot and colon operators are forms of table lookup, and methods are ordinary functions stored in the table (or more commonly its associated meta-table) which happen to take the object as their first argument. The colon operator, which can only be used as part of a function call, passes its left-hand operand to the function along with the other arguments.