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

. and : before functions?

Asked by 5 years ago

What is the difference or why do we put . before some functions and : before other functions?

0
I pretty sure ":" is a method called on an object, and "." is indexing part of a dictionary (e.g math) abnotaddable 920 — 5y

1 answer

Log in to vote
0
Answered by
ozzyDrive 670 Moderation Voter
5 years ago
Edited 5 years ago

I recently gave an answer to a very similar question.

If you're indeed referring to the dot and comma syntax when calling the default Roblox API functions, the behaviour is still the exact same. The API and its documentation uses the dot syntax for class constructors (such as CFrame.new) and colon syntax for other member functions. This doesn't mean that either cannot be called with the other syntax (although none of the constructors accept a blank class as an argument, so the comma syntax can't really be used with constructors).

For example, game.FindFirstChild(workspace, "Baseplate") is totally valid syntax. It calls the Instance.FindFirstChild function with the Workspace service as the first argument and a string Baseplate as the second argument. The function call is attempting to find a child named Baseplate from the Workspace service.

0
Not what he is looking for DeceptiveCaster 3761 — 5y
0
I'd argue that's exactly what he is looking for; what each syntax does. The difference between the two can quite clearly be seen from the answer. ozzyDrive 670 — 5y
0
he's talking about things like CFrame.Angles() and FindFirstChild() DeceptiveCaster 3761 — 5y
0
I updated the answer. They're still used like any other 'custom' member function and the difference is the exact same. ozzyDrive 670 — 5y
View all comments (3 more)
0
I'm not sure if this is correct? I would read here http://lua-users.org/wiki/ColonForMethodCall  Vulkarin 581 — 5y
0
@Vulkarin That doesn't conflict with my answer(s) at all. ozzyDrive 670 — 5y
0
The : syntax is merely sugar in that :FindFirstChild case User#19524 175 — 5y
Ad

Answer this question