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

For functions within Module Scripts, should you use . or : ?

Asked by 6 years ago

Essentially as the title says, what is the difference between : and . in Module Scripts. Here's what I mean:

local MainModule = {}

function MainModule.Test()
end

-- OR

function MainModule:Test()
end

return MainModule

Are they used for different purposes or are they basically the same? All help appreciated! Thanks.

0
I believe they are the same. I use : and haven't run into any problems. ThatPreston 354 — 6y
0
Thanks, good to know Crazycat4360 115 — 6y
1
They aren't exactly the same. Calling a function with a colon indicates it's being called as a method, which is an object-oriented programming concept. I'd suggest looking more into that online. I'd write an answer but there's too much to cover and I don't have that much time. ScriptGuider 5640 — 6y
0
Will do. Thanks Crazycat4360 115 — 6y
0
I get what you mean. Makes a lot more sense now Crazycat4360 115 — 6y

Answer this question