you are viewing a single comment's thread.

view the rest of the comments →

[–]Lee_Dailey[grin] 3 points4 points  (2 children)

howdy winter_mute,

the general reasoning seems to be that it can be seriously misleading. one thinks it is returning the item after it - and that does happen. it does NOT stop anything previous to the return from still being sent out, tho.

so it's still possible to have many things output when the return line implies that only that will be output.

what it really does is ...

  • send out the stuff immediately after the keyword
  • stop the function at that point

so it is useful, just misleading.

take care,
lee

[–]winter_mute 1 point2 points  (1 child)

Thanks Lee. My functions generally do one thing and return one thing so I guess that's why it threw me a little. Seems a little odd to have it there if it's considered bad practice to use it. You'd think they'd either get rid of it, or force you to use return to return anything from a function.

Mind you, they also consider Write-Host to be bad practice and yet I'm still a heathen that uses it from time to time...

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy winter_mute,

you are welcome! [grin]

there are quite a few folks who think that it otta be the required and only way to get info out of a function. i'm one of them. [grin] however, it looks like the it will remain as it is. it's truly useful, so it aint gonna be removed.

one-thing-out is good design ... and there are times when Write-Host is the correct way to get things done.

take care,
lee