Function return-statement

A function is returned from when reaching the end of the function body. However, immediate return from anywhere inside a function body can be done by executing a return-statement with the following syntax.


return;


The following function findMatrixElement searches an Integer matrix for a specific element. The search is done by a doubly nested for-loop, which is immediately exited when the function is returned from by executing a return-statement. At this point the correct index position has been found and assigned to the result variables row and column.