How to exit vertex function?

I have a vertex function that has a return type of void. I want to exit a function in a specific position. Is this possible on top without changing the pagereference type?

+5
source share
2 answers

At the top, the return keyword signals immediately stop processing statements in this function.

public void doNothing() {
     return;
}
+9
source

I'm not sure I understood your question correctly (a more detailed description will be useful), but it seems that you can use the return statement as follows:

public PageReference method() {
    //some your code ....
    if (some specific condition) { 
        return null;
    }

    PageReference pageRef = new PageReference('someURL');
    return pageRef;
}

Please show your code for more help.

0
source

All Articles