Hi All,
Can someone help me understand why the ‘box’ evaluates to !null in the coalescing operator but evaluates to null in an ‘if ()’ check?
public class Test : MonoBehaviour
{
public void Update()
{
// Will assign 'T' the value of 'target'.
GameObject T = target ?? new GameObject();
// ... but....
// Will evaluate to true.
if (null == target)
print("Target is null!");
}
[SerializeField] protected GameObject target;
}
The help is greatly appreciated.
Thanks,