Ever since I've started coding in WoW, and Lua consequently, I've learned a lot of tips on how to use more effective coding practices. Though, I still have a couple curiosities I'm hoping to get cleared up.
1. When I'm sharing variables across files, is it better to put them into global namespace, or within the addon?
Example:
Lua Code:
-- Method #1
local addon, private = ...
private.myVariable = 'contents'
-- Method #2
_G["myVariable"] = 'contents'
2. Is it ever ideal to use select()? More specifically, if I need to get a variable that's far down a list of arguments, would I use select(), or the "_,_,_,var" method?
Example:
Lua Code:
local _,_,_,_,_,_,_,_,_,var = MyFunction()
-- or --
local var = select(10, MyFunction())