'exit function'...always use it when returning a value?

D

darrel

This might be a really dumb question, but when should/shouldn't one use the
exit function command?

If I have this:

function()
if something then
do this
return that
else
do this
return that
end if
end function

should I instead always use this instead:

function()
if something then
do this
return that
exit function
else
do this
return that
exit function
end if
end function

or does the very act of returning something exit the function?
 
R

Raterus

"or does the very act of returning something exit the function?" <-- yes

You really only would need to use exit function if you were familiar with the old VB6 way of functions, where you had to set the function name = return value. But using the return statement immediately exits the function (and why shouldn't it?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top