- Joined
- Aug 24, 2004
- Messages
- 11
What is the purpose of back to back return statements in a function? I'll use an example from fugly's Create Aura script to show you what I'm talking about:
I have seen quite a few people do this in their code, but I don't understand the purpose. I can only assume that if the first return statement fails Warcraft will attempt the next command, kind of like a try/catch clause in C++. But I NEVER see anybody test for the error condition. So what is the point of having a second return statement if your script will only crash again because of a null pointer error in the function that called this function?
Code:
function H2G takes handle h returns group
return h
return null
endfunction
I have seen quite a few people do this in their code, but I don't understand the purpose. I can only assume that if the first return statement fails Warcraft will attempt the next command, kind of like a try/catch clause in C++. But I NEVER see anybody test for the error condition. So what is the point of having a second return statement if your script will only crash again because of a null pointer error in the function that called this function?