Question about tables

Maybe I’m misunderstanding something but I was wondering why, when we store functions inside of tables, we reference them using the dot operator, but when we store other types of data, we use the square brackets.
For example:

Local tabl = {}
Table.funct = function(thing)
    print(thing)
end
Table["amount"] = 5

Why don’t they both use the same syntax?

You can use either syntax.

local table = {}
table["amount"] = 5
print(table.amount) -- prints 5
1 Like

The example you gave wouldn’t be a valid way of creating a function in that table anyway, a working way would be this:

tabl.funct = function()

end

Also, you can use both, as @itsLevande said above.

1 Like

Thanks for the information. I changed it accordingly