Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Calling a function on a table, and how does this code work?

Asked by 7 years ago
function module:GetDatabase(sheet)
    local database = {}
    function database:PostAsync(key, value)
        return doPost(sheet, key, value)
    end
    function database:GetAsync(key)
        return doGet(sheet, key)
    end
    return database
end

So, from my understanding, whenever PostAsync() is called, doPost is returned, and whenever GetAsync() is called, doGet is returned? Am I correct in this understanding?

Also, functions are being called on the table? This code is confusing me for some reason.

0
To clarify: this is someone else's code that I'm trying to learn from. I'm sure you figured that out, though. fireflame09225 11 — 7y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
7 years ago

Whenever you call :PostAsync() on the module, which is what the script is in, it'll return a function doPost() that I'm assuming uses PostAsync. This looks like code for a Sheets API.

0
I've been using and learning from his source code and trying to make it into an idea I've had for a while. Kinda excited about this project. fireflame09225 11 — 7y
Ad

Answer this question