What does  ConfirmationDelegate.initialize() do?

I'm getting stuck in some UI code and have tracked it down to the fact that I don't understand the ConfirmationDelegate documentation that includes:.
function initialize() {
ConfirmationDelegate.initialize();
}



I am using the initialize() function to receive an argument with which to modify its behavior of in its onResponse() callback, like:
function initialize(_openNavMenuOnClose) {
openNavMenuOnClose = _openNavMenuOnClose;
ConfirmationDelegate.initialize();
}


But I am getting different responses from my code when running in the Sim and on a device.

So my question is : what does the call to ConfirmationDelegate.initialize() actually do?

  • what does the call to ConfirmationDelegate.initialize() actually do?

    It explicitly initializes the base class. That should be enough to answer your original question.

    Are you really happy following rules that seem to have no basis?

    The general rule is to call initialize of the base class explicitly. If you don't explicitly initialize the base, your derived object could end up in an indeterminate state. That would be bad. If a class doesn't explicitly define initialize(), then it will get an implicit one that does nothing; I have not double-checked and I can't find the supporting documentation, but I'm almost certain that the implicit initialize will not call initialize on the base class.

    The documentation for ConfirmationDelegate should read:

    There is no initialize() method explicitly defined for ConfirmationDelegate, so it seems to me that it is okay for there to be no documentation for it. You don't absolutely have to call it because it does nothing.

    That said, MonkeyC doesn't generate warnings or errors for a lot of dangerous things. If you need to explicitly initialize a base class and you fail to do so, you are likely to get some difficult to debug problems.

    My personal rule of thumb is to initialize the base class explicitly for all types, whether they have an explicit initialize or not.

    Travis