If Lua has no class, why does it have a dot operator?
Eg. In string.find
, is string
a class with static/class method find
?
In your example, find
is an entry in the table string
It is syntactic sugar for string["find"]
It could be defined like so:
local string = {
"find" = function()
-- find stuff
end
}
or
local string = {}
string["find"] = function()
-- find stuff
end
or
local string = {}
string.find = function()
-- find stuff
end