Help with table.find

Hello im using table.find to tell if something exists in a table, but I want to find what the number is in so I can remove it from the table. Any solutions?

table.find returns that number.

local t = { "a", "b", "c" }
table.remove(t, table.find(t, "b"))
print(t[2]) -- c
1 Like

i am idiot, thank you. how could I have not conceived that

Because of table.remove, elements to the right are shifted 1 index down to the left. So "c" gets moved to index 2 since the removal of "b" causes a gap.

1 Like