Ellipses assignment?
I've been getting into WoW addon development and for the moment, I'm mainly looking through other people's code to understand what's going on. I keep seeing this type of thing all over the place and I can't, for the life of me, figure out what it means.
local _, ns = ... They then go on to use the ns variable, but I don't know how it has any data in it. What are they assigning it to exactly? |
It's a table that gets passed to all files of an addon
https://wowpedia.fandom.com/wiki/Usi...ddOn_namespace |
Sweet, that makes a lot of sense. Thank you!
|
For a more in-depth explanation, ... in Lua is called a vararg, short for variable arguments. It is used when defining a function when the number of arguments being passed to it is unknown.
Lua Code:
There's another level to WoW's coding we don't see, which is written in C++. When this internal structure loads an addon, each file in the addon is actually one big function. We see: Lua Code:
What's actually happening: Lua Code:
This privateTable is shared across all loaded files within an addon, basically each .toc file gets its own table. |
All times are GMT -6. The time now is 07:03 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI