On the basis of the assertion, please help to answer it

I encountered a fundamental problem when looking at assertions in official documents.

check(Mesh != nullptr);
check(bWasInitialized && "Did you forget to call Init()?");

What does the “&&” symbol in the code above mean as a parameter?

&& is boolean operator of AND operation. it not just for if statement thing it work any mathematical operation on 2 boolean values.

In C++ all types (at least primitive once like int or float) can be auto casted to bool and if there bits in memory all zeros they equal to false, if they have atleast one bit with value 1 they equal true. Thats why this operator can be used on other types then just Boolean.

Case you showed use that fact simply to pass the error message in case if bWasInitialized is false as assertion fail only shows failed condition :slight_smile: since literal string always gonna be treated as true, it using && operator to make that literal string neutral to rest of Boolean condition of check

Note that check fail only if condition in it is false, it can be any boolean, if you do something like this check(false) it will always fail

Looks like it has the same effect as putting that string in a comment. I womder why they didnt just do that.

Because i as i said, if assertion fails this will print out in the log explaining issue or giving hints like in this case, while comment would not and you would need to search the code to find it. One of biggest problem with assertion system is that it’s too cryptic for beginners, so this practice ease this out.