Can you use an object’s existence as the condition of an if statement in Haxe? If so, how?
var b : Bullet = collide("bullet", x, y);
if (b) {
b.destroy();
}
I’ve also tried testing it against the Null type, but that doesn’t seem to work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As kirilloid mentions in the comments, try checking if
bis not null:It was decided for Haxe not to have the
if(b)syntax for a number of reasons. You can find a discussion on the topic on Google Groups: Test if exists.