Sunday, 21 August 2016

Null Is Not Void

There is conceptual difference between void, which is nothing, and null, which is more like not  something. The word void means there is no intention of anything to be presented, whereas null implies that there can be something. We may add if(target != null) and can say that target can be empty or it can be Zombie. When target isn’t a zombie, target is null; when it is there, it’s Zombie.

We may add if(target != null)—in more readable English, “if the target is not null”—and then conditionally execute the following code block. In the case where we have a target, we can draw a line from the camera’s transform.position to the target’s transform.position. This code alleviate the error, and thus we don’t have to worry about sending Draw.DebugLine an error-inducing null reference.
No comments :

No comments :

Post a Comment