LearDev
(Lear)
April 23, 2023, 11:39pm
#1
I would like to know if you can insert a value into a table position greater than the number of values in that table plus 1.
for instance, in a table that has only 3 pre-existing values, can you insert a string into position 1000?:
local foodtable = {"French Fries", "Sandwich", "Apple"}
table.insert(foodtable,1000, "Hamburger")
Haven’t found any topics on this yet, anything would benefit!
typedwaves
(typedwaves)
April 23, 2023, 11:47pm
#2
I’m not sure why you’d want to insert a value more than what the table has, however you can do it by setting it like it’s a dictionary, foodtable[1000] = "Hamburger"
2 Likes
Uzixt
(Uzi)
April 23, 2023, 11:48pm
#3
table.insert(foodtable,1000, "Hamburger")
will indeed work aswell
2 Likes
typedwaves
(typedwaves)
April 23, 2023, 11:49pm
#4
Ah, I was assuming it wouldn’t work with my answer as it seemed like they had tested it haha
1 Like
system
(system)
Closed
May 7, 2023, 11:49pm
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.