When is a function a bad investment?
When is a function a bad investment? "When there's no return"
This is a pun. The joke refers to good investing practices as well as programming. The word return is the center of the pun, and it means both "money that you get back from an investment" and "value that is passed back from a function".
A function that does not pass back a value is called a void function, but they are useful if the function changes the state of the object that it is being called on, or if it affects some other part of the world (such as a draw function that draws something to the screen but doesn't return anything.)
This joke is pretty bad.