天天看點

傳回函數多個傳回值

一個powershell函數可以有多個傳回值。要接收這些傳回值,隻需要将傳回值賦給多個變量:

function get-datetimeinfo

{

# value 1

get-date -format 'dddd'

# value 2

get-date -format 'mmmm'

# value 3

get-date -format 'hh:mm:ss'

}

$day, $month, $time = get-datetimeinfo

"today is $day, the month is $month, and it is $time"

from:http://blog.vichamp.com/powershell/tip/2013/09/09/returning-multiple-values/

繼續閱讀