Skip to main content
Put question in the title, not just the vague subject area
Source Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

Regarding if check for objects Is `if (gameObject)` the same as `if (gameObject != null)`?

Very simple question:

If you have a Game Object, and you want to check if it exists, is

if (gameObject) { }

the same as

if (gameObject != null) { }

and if not, what is actually being evaluated in the first statement?

Regarding if check for objects

Very simple question:

If you have a Game Object, and you want to check if it exists, is

if (gameObject) { }

the same as

if (gameObject != null) { }

and if not, what is actually being evaluated in the first statement?

Is `if (gameObject)` the same as `if (gameObject != null)`?

If you have a Game Object, and you want to check if it exists, is

if (gameObject) { }

the same as

if (gameObject != null) { }

and if not, what is actually being evaluated in the first statement?

added tag
Link
Zibelas
  • 5k
  • 2
  • 15
  • 26
Source Link
Marcel
  • 1
  • 1
  • 1

Regarding if check for objects

Very simple question:

If you have a Game Object, and you want to check if it exists, is

if (gameObject) { }

the same as

if (gameObject != null) { }

and if not, what is actually being evaluated in the first statement?