Jump to content

isNil?


dugasz1

Recommended Posts

Posted

Hello!

How can i detect if a array's member exist or not?

  
local array = { 
    {"wathever", "wathever"}, 
    {"wathever", "wathever"}, 
    {"wathever", "wathever"}, 
} 
if(array[4] == nil) then  
    --Do Something 
end 

Beacause this doesn't work. It throws attempt to index field error.

Edit:

I know i can count the table's lenght and check it but i want detect if

Sorry for lot of questions and thanks for the answers! :)

Posted

I tought it too but no somewhy.

(I think it shouldn't matter but in my script it's a 3 dimension array but i guess it should work with a single variable)

Sorry for lot of questions and thanks for the answers! :)

Posted

I try your code on http://www.lua.org/demo.html and it's working.

Check your script, maybe there's another problem. Also try to loop through the table and print it after you add value on table, to check if the table is working or not.

Open for cooperation.

Discord: idarrr#7935

Posted

Today i tried it again and it worked. I don't know what was wrong last time. Thank you

Sorry for lot of questions and thanks for the answers! :)

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...