私は最近配列を使用しており、Python の「in」演算子が本当に欠けています。
例えば:
if ("hello" in ["hello", "there", "sup"]):
print "this prints :)"
次のように、「ThereExists-Object」関数を作成することで、少し補いました。
function ThereExists-Object([System.Management.Automation.ScriptBlock] $sb)
{
return ($input | where $sb) -as [bool]
}
New-Alias -Name ThereExists -Value ThereExists-Object
例えば:
if ($arrayOfStuff | thereexists { $_ -eq "hello" } )
{
write-host "this prints too"
}
明らかに、これに対して別の関数を定義することもできます...しかし、この仕事を成し遂げることができる、私がよく知らない構文糖衣があるかどうか知りたいです。
それで... ありますか?