something {} is actually a way to pass a parameter to a function.
local function something(t: {}) -- takes one value, which is a table
print(t[1])
end
something {1} -- prints "1"
something({1}) -- This is what the above line is equivalent to.
It can’t be used with multiple arguments though.
local function something(t: {}, t2: {}) -- takes 2 values this time
print(t[1])
print(t2[1])
end
something {1} -- Would print 1 then error (as t2 isn't passed)
something {1}, {2} -- Assuming above line isn't there, it'll error saying Expected identifier when parsing expression, got ','
something({1}, {2}) -- Assuming the above lines aren't there, this will print 1 and 2 correctly.
This also works with strings!
local function something(str: string)
print(str)
end
something "Hello, World!" -- Hello, World!
something("Hello, World!") -- Hello, World!
Only works with 1 argument, no difference.
Personally I think this just makes the code look worse with strings, but better with tables. It’s a preference after all though. Saying it again, it does come with the limitation of being able to pass one argument only.