If condition executed even on false [unity c#]


This is added in a gameobject with just Transform inspector component

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class Test : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            
        }
    
        // Update is called once per frame
        void Update()
        {
            var b = false;
            Debug.Log("Outside If condition :" + b);
            if (b) ;
            {
                 //How come this is executed ????
                Debug.Log("Inside If condition :" + b);
            }
        }
    }



<br> Output Log

  [1]: https://i.stack.imgur.com/bCyK9.png



Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email