What does the “@” symbol do in Powershell?

前端 未结 5 1925
青春惊慌失措
青春惊慌失措 2020-11-28 03:47

I\'ve seen the @ symbol used in PowerShell to initialise arrays. What exactly does the @ symbol denote and where can I read more about it?

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 04:41

    In PowerShell V2, @ is also the Splat operator.

    PS> # First use it to create a hashtable of parameters:
    PS> $params = @{path = "c:\temp"; Recurse= $true}
    PS> # Then use it to SPLAT the parameters - which is to say to expand a hash table 
    PS> # into a set of command line parameters.
    PS> dir @params
    PS> # That was the equivalent of:
    PS> dir -Path c:\temp -Recurse:$true
    

提交回复
热议问题