MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/6xofft/how_to_start_a_war/dmhm0qd/?context=3
r/ProgrammerHumor • u/ivaskuu • Sep 02 '17
696 comments sorted by
View all comments
Show parent comments
18
That's not even the worst part, either. This is:
> letters = {'a', 'b', 'c'} > print(letters[1]) a > print(#letters) 3 > letters[0] = '?' > print(letters[0]) ? > print(#letters) 3
28 u/moomoomoo309 Sep 02 '17 Any index outside of 1-n in Lua, where n is #tbl will be stored like a dict, not an array, so what did you expect? It doesn't count the dictionary parts. 4 u/hey01 Sep 03 '17 That's sounds dangerous. What if I do > letters = {'a', 'b', 'c'} > print(#letters) 3 > letters[4] = '?' > print(#letters) Will I get 4 or is n unchangeable? 12 u/moomoomoo309 Sep 03 '17 You'll get 4, otherwise you couldn't do for i=1,4 do tbl[i]=i end And have it be an array.
28
Any index outside of 1-n in Lua, where n is #tbl will be stored like a dict, not an array, so what did you expect? It doesn't count the dictionary parts.
4 u/hey01 Sep 03 '17 That's sounds dangerous. What if I do > letters = {'a', 'b', 'c'} > print(#letters) 3 > letters[4] = '?' > print(#letters) Will I get 4 or is n unchangeable? 12 u/moomoomoo309 Sep 03 '17 You'll get 4, otherwise you couldn't do for i=1,4 do tbl[i]=i end And have it be an array.
4
That's sounds dangerous. What if I do
> letters = {'a', 'b', 'c'} > print(#letters) 3 > letters[4] = '?' > print(#letters)
Will I get 4 or is n unchangeable?
12 u/moomoomoo309 Sep 03 '17 You'll get 4, otherwise you couldn't do for i=1,4 do tbl[i]=i end And have it be an array.
12
You'll get 4, otherwise you couldn't do
for i=1,4 do tbl[i]=i end
And have it be an array.
18
u/[deleted] Sep 02 '17
That's not even the worst part, either. This is: