View Single Post
07/01/14, 03:49 AM   #18
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by Tar000un View Post
Hmm why i read it as a table ?
Ok, time to sleep i think. x)
The Saved Var acessor object can also be read as a table (int and string indexes). Yet also #SavedVarAccessor will return 0.

My best guess is that they fake those two being a table via metafunctions (specifically they have some code for indexing attempts on not-really existing indexes). And they just did not bother to give # a proper meta function, so it won't return anything usefull.

Code:
SavedVar.SomeValue
is equal too
Code:
SavedVar["SomeValue"]
is equal too
Code:
SavedVar.[metatable].getIndex("SomeValue")
Edit: That could mean that "ZO_LinkHandler_ParseLink()" is not actually parsing the link and giving you a table interpretation.
Instead it returns an object that encapsulates the link and gives you some functions to extract data from contained link. It just hides the fact that those are functions behind a fake table.

Edit2: More correct the final piece of code would look like this:
Code:
getmetatable(SavedVar).__index(SavedVar, "SomeValue")

Last edited by zgrssd : 07/02/14 at 02:41 AM.
  Reply With Quote