PowerShell - 関数(可変長引数)
引数は変数$argsという配列にわたされる。
test.ps1
function foo { $args.GetType() foreach( $i in $args ) { Write-Host $i } }
結果
PS C:\> . C:\test.ps1 # 関数読み込み PS C:\> foo 1 2 3 IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Object[] System.Array 1 2 3 PS C:\> foo "a" "b" "c" IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Object[] System.Array a b c