A bit of struggle here

So I commented a part of my script and once I uncommented this happened
“The name “IsItPair” does not exist in the current context”

        for (int i = 0; i <= 17; i++) {

            if (IsItPair (i)) {
                Debug.Log("The number is pair" + i);
            } else {
                Debug.Log("The number isnt pair" + i);
            }

        }

Can someone help me?

bump

What is IsItPair? Show us the code.

Its just a boolean. Thats pretty much all the code I got for that

We need to see the declaration for IsItPair. If there is no declaration to show us, then that is your problem.

A new struggle

So I have this & I get the error “Cannot implicitly convert type void to bool”
How can I fix that?

    void IsItPair(int numero)
    {
        if (numero % 2 == 0)
        {
            Debug.Log("It is pair");
        }
    }



        for (int i = 0; i <= 17; i++) {
            if (IsItPair(i)) {
               Debug.Log("The number is pair" + i);
            } else {
                Debug.Log("The number isnt pair" + i);
            }

        }

Yup. IsItPair doesn’t return a bool. So the compiler is confused. You probably want.

    bool IsItPair(int numero)
    {
        if (numero % 2 == 0)
        {
            return true;
        } else {
            return false;
        }
    }
1 Like

Thank you so much