Bool get false without set to false

Could someone share some light on what i am missing in this code or is it me?

The cardOK is set to true in the beginning and the code is NOT hitting the if statement “if (cardOK = true && _card.name.Substring(1, 1) == “A”)”, the Coroutine is not accessed, but cardOK still report false in #2?

print("1) " + cardOK); = true
print("2) " + cardOK); = false

Is there anything i am missing here as it should report true as it is set as that in the beginning.

bool cardOK = true;

        // CHECK IF CARD(S) MOVED FROM THE SAME LINE AS DROPPED
        if (_fromLine == _toLine) {
            StartCoroutine(MoveBackCard(_card, _engine.cardDragStartingPosition, _card.GetComponent<Renderer>().sortingOrder));
            cardOK = false;
        }
      
        print("1) " + cardOK);
        // CHECK IF ACE, IF SO MOVE BACK TO SENDER
        if (cardOK = true && _card.name.Substring(1, 1) == "A") {
            print("HIT");
            StartCoroutine(MoveBackCard(_card, _engine.cardDragStartingPosition, _card.GetComponent<Renderer>().sortingOrder));
            cardOK = false;
        }

        print("2) " + cardOK); <<<<< THIS IS FALSE WITHOUT SET TO FALSE

You have 2 if statements there that both set to false. It’s not hitting either?

You’re probably changing the state of the bool either somewhere else, or in the coroutine you’ve started above.

Make sure you’re not running previous instances of coroutines as well as debugging _fromLine == _toLine statement above.

Do you get Print Hit in console as well? I mean you mentioned that co-routine is not executed.
But I am asking, in case
cardOK = true && (assignment)
should be
cardOK == true && (comparison)

Following what suggested by others, put debug log in first condition statement.
If is hit, then you found your problem.

Is this encapsulated in method?

1 Like

I am blind, i changed the:

cardOK = true && (assignment)
should be 
cardOK == true && (comparison)

…and it worked as it should.

THANK YOU.