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

What do the double parenthesis without anything inside do and why do people use them?

Asked by 5 years ago

This may seem like a dumb question but, what do the double parenthesis without anything inside exactly do? I've seen them quite often, though I'm still not too sure of what their purpose is. The internet doesn't exactly give specific answers. e.g.

1local function addNumbers()
0
Parameters are supposed to go inside double parenthesis. Geobloxia 251 — 5y

2 answers

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

when your defining a function, you'll often specify arguments that will be passed when the function is called. the parameters are set in the parenthesis..

for instance:

1function addNumbers(numberA, numberB)
2    return numberA + numberB
3end
4 
5local result = addNumbers(1,2)
6print(result)

or

1function sayHello()
2    print("Hello there")
3end
4sayHello()

or

1function greet(personsName)
2    print("Hello, "..personsName)
3end
4greet("JustPhysical")

learn more here

Ad
Log in to vote
1
Answered by 5 years ago

Parameters are left blank usually for simple functions. However, you will see parameters in the double brackets in more complex functions. Events(or most, I'm not sure) will give a parameter depending on the event (ex. a touched event provides the part that touched the block)

In conclusion, empty brackets are not commonly found in functions, but they do exist.

Answer this question