Exiting a method prematurely?
BlitzMax Forums/BlitzMax Beginners Area/Exiting a method prematurely?
| ||
This is a fairly simple question. Many times I wish to exit a method early providing that requirements have been met. An example is collision detection. I make a ship that looks through all of the enemy shots and sees if it has collided with any. Ships are destroyed after one shot. Currently even if the ship has found a enemy shot it still continues to look for other hits. This is because all shots are being scanned through. I would like to exit early if it does find a collision. I know with functions one just calls the return command. Is there an similar command for early ending in methods? |
| ||
Return ;) |
| ||
Ah so methods may end with return also? |
| ||
yeap |
| ||
Just a note: if your method does not have a return type, you can just use 'Return' (no parameters) to exit the Method/Function (obviously without returning anything.) Although, in your case, I assume you need to return something :) EDIT: I think a return call with no parameters would effectively do the same as this (*return* Null) - given you are in a SuperStrict environment, and that your Method/Function has a return type. |