Posted 04 November 2012 - 01:45 PM
Does saying t = {}
the same as saying t = {nil,nil,nil}
the same as saying t = {nil,nil,nil}
t[5]="hello"
you are setting key 5 of the table to the value of "hello". Any Key that isn't set is automatically nil, so nil is technically the default value of every key. t={nil,nil,nil}
is essentially the same as calling:t={} t[1]=nil t[2]=nil t[3]=nil
but since t={} makes all the values in the table nil by default, they are again, essentially the same thing, so t={nil,nil,nil}
is redundant, as well as t={} t[1]=nil
etct={nil,nil,nil,"hello"}
, it would be the same as calling t={} t[1]=nil t[2]=nil t[3]=nil t[4]="hello"
thus making it different, however calling t={} t[4]="hello"
would be a much better method as it is shorter and achieves the same result.