Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: