I have an apex function which has a void return type. I want to exit the function at a specific position. Is this possible in apex without changing return type pagereference?
8
votes
2 Answers
17
votes
0
votes
I'm not sure that I correctly understood your question (more detailed description will be useful), but it seems that you can use a return statement by the following way:
public PageReference method() {
//some your code ....
if (some specific condition) {
return null;
}
PageReference pageRef = new PageReference('someURL');
return pageRef;
}
Please show your code for a more target help