I would like to have a function that checks if a condition is true run before a specific function is called. My goal is to have one line of code (the function being called) in another function. This function should run before any other code is executed. Here is some pseudocode to demonstrate what I mean:
function checkFunction(){
//checks if a condition is true if so end function, else continue function
}
function aFunction(){
checkFunction();
//some code
}
I know I can make a conditional statement that contains a return, but I would like to keep it this short if possible.
Thank you guys for your time.
There’s nothing designed specifically for what you want, and its verging on bad practice anyway. But you could get it pretty succinct by just writing something like: