RETURN keyword

In an interview Jeffrey Snover was asked:
“Seeing the way PowerShell has evolved, what is your biggest regret?”
He answered:
“The return keyword was a misstep. Because any command output prior to return is also included, it doesn’t behave intuitively.
…” ( http://www.brianbunke.com/blog/2017/04/11/snover-ama/ )

Can anybody explain this, with some examples?

In other programming languages returns a function only what’s specified with the key word “return”. In Powershell a function returns everthing what’s left in the “output channel”.

function Return-everything {
‘Simple string’
‘Another simple string’

Return 'Return should only return what comes after the key word return, right?'

}


This function in other languages would only return the content of the last line. Try it! :wink: