Help with using table methods please.

Hello facepunch,
I’m just curious to ask if anyone is willing to help me, I’m trying to figure out what are the differences of these tables below and when/why would you use these methods.
local = myMethod1 ={
[“string”] = true – what’s the actual use of doing the square brackets in this?

local myMethod2 = { [var1= “hey”, var2=20]}

This would give you the best understanding of tables, this is what i first looked at :

neither of the examples you provided is valid syntax.

for the first one however, assuming you mistyped the first equal sign; what you’re doing is initializing the table with a string-key.

calling this

local myMethod1 ={
    ["string"] = true

is identical to calling this

local myMethod = {}
myMethod.string = true

or this

local myMethod = {}
myMethod["string"] = true

Thank you, I’m getting a better understanding now.

[editline]2nd October 2016[/editline]

Thanks, I’ll check it out:)

I really like the official PIL guide. - Tables - an introduction to tables - Table Constructors - this is what you’re asking about

Thanks, a big help:)