Quantcast metatables help to understand? - WoWInterface
Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-14-19, 09:51 PM   #1
A Murloc Raider
Join Date: May 2019
Posts: 8
metatables help to understand?

So i've been looking into meta tables, but i feel like use it would create more unnecessary code...
...unless i'm looking at it wrong.

So in the example i'm showing i'm wandering if i'm using it correctly.

can someone give a brief run down on why you need -or- should use metatables

Lua Code:
  1. local SomeClass = {}
  3. metatable = {}
  4. setmetatable(SomeClass, metatable)
  6. function SomeClass:DoSomething ( table, ... )
  7.     return "Something Happens"
  8. end
  10. function metatable:__call( table, ... )  
  11.     return SomeClass:DoSomething(table, ... )
  12. end

this being like this, i can just print(SomeClass()) and it would result in "Something Happens" ... buut I fell like itd be simplier to just do a static call print(SomeClass: DoSomething()) ... Space in ther to prevent emoticon and static may be the wrong term (php dev background)

Last edited by urakkaamyx : 05-14-19 at 10:03 PM. Reason: added more explaination
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » metatables help to understand?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off