Return $var from function or $script:var?

by Oct 5, 2013

Could someone explain or refer me to a good site that explains when or why you would use one of the following situations.

 

function func {
#manipulates data in $var
return $var
}

 

Or I could define $var as a script scope variable and manipulate its data in functions and not return $var:

 

function func {
#manipulates data in $script:var
}

I realize there can be multiple ways of doing things and one way isn't alway necessarily better than another; but I don't want to learn myself something now only to realize later I'm getting in trouble because I didn't foresee something I don't understand now.

 

Thanks!