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

Are parenthesis needed here?

Asked by 8 years ago

Is there a difference between this

local a = Instance.new(t, p or game.Workspace)

and this

local a = Instance.new(t, (p or game.Workspace) )
2
Not really. :) Parentheses aren't necessary in this situation. :P In my opinion (or understanding), the Parentheses are like the Mathematical ways (Example: P.E.M.D.A.S.); Parentheses comes first (and I think this does the same affect for 'If' statements as well :o ) when it comes to a specific Mathematical term. :) TheeDeathCaster 2368 — 8y

1 answer

Log in to vote
4
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago

In this case, there is no difference. However, if you wanted to say something like this:

local r = false
local a = Instance.new(t, (r and p or game.Workspace) )

It's better to have parentheses for expressions with several and's and/or or's

0
...but the parenthesis would do better clarifying the o-o-o on the `and` and `or`, and not on the comma BlueTaslem 18071 — 8y
Ad

Answer this question