Originally Posted by Vladinator
On the subject (kind of), is it possible to add a new function, let's say:
string:fc = function() return self:sub(1, 1):upper() end
local str = "hello world"
print(str:fc()) -- prints "H"
Not sure if it's doable without causing taint and break other addons, considering string is quite global.
|
The only way to directly define a colon-notation version of the function is:
Code:
function string:fc()
return self:sub(1, 1):upper()
end
This is perfectly legal and non-tainting, since the Lua string library in no way controls or impacts the WoW API.
To do it the way you alluded to, you'd need to do it thusly:
Code:
string.fc = function(self)
return self:sub(1, 1):upper()
end
At that point, you'd be able to call the function using colon-notation.