I’m fooling around with metatables and I though to myself, what’s the point of adding Self to Class? As in the example below, you can perfectly run this metamethod, if that’s the correct Terminology, without putting Self into the mix, I’d also like to understand a bit more on Self being an automatically provided argument when writing these functions. Could anyone fill me in?
--// Self applied
local Class = {};
Class.__index = Class
local Self = {};
setmetatable(Self, Class)
function Class.SetString(Self, String) --// Provided argument?
Class.String = String
return Class.String
end
print(Self:SetString("Hello!")) --// -> “Hello!”
--// Self excluded
local Class = {};
Class.__index = Class
function Class.SetString(Self, String)
Class.String = String
return Class.String
end
print(Class:SetString("Hello!")) --// -> “Hello!”
Thanks! If there’s anything else interesting that I should know, please provide a link!

1 comment
I’m so sorry I left this blank. My knowledge of programming has widely increased, and I understand this subject now fully. I came back to this and realized I never accepted. Please do accept my deepest of apologies.