5

I seem to recall Lua has something similar to Ruby's method_missing. Or am I remembering incorrectly?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Dexygen
  • 12,287
  • 13
  • 80
  • 147

1 Answers1

8

The __index and __newindex of a table's metatable can be used to the same effect as Ruby's method_missing.

JoeG
  • 12,994
  • 1
  • 38
  • 63
  • Yes, upon more vigilant googling I found this URL http://www.lua.org/pil/13.4.1.html from the Lua manual which states: "when we access an absent field in a table .... such access triggers the interpreter to look for an __index metamethod" – Dexygen Oct 11 '11 at 20:50