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

Why do they use this sometimes?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I never understood this:

if (game.Workspace.Base.Tag.Value == 'Made by UltraUnitMode') then
game.Workspace.Base.Tag.Value == 'Made by No One'
end

2
What didn't you understand about it? If the ValueObject Tag located under Base's value is equal to "Made by UltraUnitMode" then the script will change the value to "Made by No One". M39a9am3R 3210 — 9y
1
I meant the ( ) UltraUnitMode 419 — 9y
0
You should have said that in the question. (Please edit it) BlueTaslem 18071 — 9y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

There is not a good reason for the () in a condition in Lua. They are redundant and don't make things clearer. Perhaps it makes it easier to add logical operators like not and and to it, but that's probably not worth it.

However, many other programming languages require () around conditions.

  • JavaScript
  • Java
  • C
  • C++

It's most likely a hold-over from the author's experience in that language.

It's unnecessary in Lua, and is usually unnecessary in those lanuages. Go, which has a similar syntax to C, C++, Java, JavaScript did get rid of the () (and actually made them illegal).

Ad

Answer this question