Jump to content

Recommended Posts

I wanted to ask if there is a way to check what index the value in the table is

for example,

t = {}

table.insert(t,"Hello")

table.insert(t,"HELLO")

table.insert(t,"HI")

if index==1 and value=="HI" then -- false
  --do something
elseif index==0 and value=="HELLO" then --false
  --do something
elseif index==2 and value=="HI" then --true
  --do something
else --etc.
  --do something  
end

--If someone does not distinguish the index from the value then the index is for example [0,1,2,3 ...] and the value is an element for example
print(t[1]) -------------> 'HELLO'

  

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...