Why this piece of code

Why Rick has used this piece of code if (!death VFX) {return; }. ? I have not understood this code.

Hi Farhad,

(!deathVFX) translates to (deathVFX == null). return; terminates the method immediately.

if (!death VFX) {return; } means: If there is no object assigned to the deathVFX variable, terminate the method immediately and do not execute the rest of the method.

If the deathVFX variable was “empty” (= null), we would get an error message if we tried to access the non-existent object.

Did this clear it up for you? :slight_smile:

1 Like

Thank You Nina.

You’re welcome. :slight_smile:


See also:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms