as far as i know , the constructor return nothing , not even void ,
and also
return ;
inside any method means to return void .
return
can be used to leave the constructor immediately. One use case seems to be to create half-initialized objects.
One can argue whether that is a good idea. The problem IMHO is that the resulting objects are difficult to work with as they don't have any invariants that you can rely on.
In all examples that I have seen so far that used return
in a constructor, the code was problematic. Often the constructors were too big and contained too much business logic, making it difficult to test.
Another pattern that I have seen implemented controller logic in the constructor. If a redirect was necessary, the constructor stored the redirect and called returned. Beside that these constructors were also difficult to test, the major problem was that whenever to have to work with such an object, you have to pessimistically assume that it is not fully initialized.
Better keep all logic out of the constructors and aim for fully initialized, small objects. Then you rarely (if ever) will need to call return
in a constructor.