Y
Y
yraiv2022-03-07 12:04:20
Unity
yraiv, 2022-03-07 12:04:20

Why does if fire if conditions are not met?

There are two lists, I want that if they were not empty, then the code was called, but it is called even when 1 of the lists is completely empty.

Debug.Log(ZombieMaxArrayList.Count);  //тут 0
        Debug.Log(zombieArrayNew.Count); // тут 1
        if (zombieArrayNew != null && ZombieMaxArrayList!= null) // я как-то не так проверку делаю на то, пустые списки или неТ?
        {
            Debug.Log(ZombieMaxArrayList.Count);//тут 0
            Debug.Log(zombieArrayNew.Count);//тут 1

      }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GFX Data, 2022-03-07
@yraiv

Everything works correctly for you. Both lists exist, the reference to them is not null, since they have a length.
Probably it should be like this:

if (zombieArrayNew.Count > 0 && ZombieMaxArrayList.Count > 0)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question