Monday, February 4, 2019

Chain of Command - avoiding the next call

This is possibly something that needs to be used very sparingly if at all, but apparently there is a way (up until the latest version - v8.1) to avoid calling the next() call when using chain of command.

The key is to use double nested conditions:

//this will not work "call to 'next' should be done only once and unconditionally"
    protected void chooseLinesPackingSlip(boolean _append)
    {
       If (true)
{
           this.somethingElse(_append);
           return;
       }

       next chooseLinesPackingSlip(_append);

    }

//this will work
    protected void chooseLinesPackingSlip(boolean _append)
    {
       If (true)
{
    if (true)
    {
               this.somethingElse(_append);
               return;
           }
       }

       next chooseLinesPackingSlip(_append);

    }