Last active
August 29, 2015 14:01
-
-
Save aetos382/b90d18c96ca0ed63e04d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Hoge | |
{ | |
param( | |
[ValidateNotNullOrEmpty()] | |
[string[]] $x = @()) | |
@($x) | % { ... } | |
} | |
$x = @() | |
<# | |
この辺で、$x に値を追加していく。 | |
結果的に $x は空の場合もあるとする。 | |
#> | |
# 空だとエラーになるので、判別しないといけない。 | |
if ($x) | |
{ | |
Hoge $x | |
} | |
else | |
{ | |
Hoge | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Hoge | |
{ | |
param( | |
[PSValidator.ValidateNotEmptyString()] | |
[string[]] $x = @()) | |
@($x) | % { ... } | |
} | |
$x = @() | |
<# | |
この辺で、$x に値を追加していく。 | |
結果的に $x は空の場合もあるとする。 | |
#> | |
# 空でも大丈夫。 | |
Hoge $x | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Hoge | |
{ | |
param( | |
[ValidateLength(1, [int]::MaxValue)] | |
[string[]] $x = @()) | |
@($x) | % { ... } | |
} | |
$x = @() | |
<# | |
この辺で、$x に値を追加していく。 | |
結果的に $x は空の場合もあるとする。 | |
#> | |
# 空でも大丈夫。 | |
Hoge $x | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Hoge | |
{ | |
param( | |
[ValidateScript({ Test-Path $_ })] | |
[string[]] $x = @()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment