This answer includes a Powershell like of code that splits $env:path
, applies a filter and puts the result together, to store it in $env:path
.
$path = ($path.Split(';') | Where-Object { $_ -ne 'ValueToRemove' }) -join ';'
I was reading this code, and then, suddenly, a wild -join ';'
appears. How does this work? What is the concept behind this? I would expect (<expression)
would eventually become some object, but then this like reads <object> -join ';'
, so the join part would still be some independent token. How is it evaluated? I can see that it obviously does "the right thing", but how and why does it work? How exactly does Powershell evaluate this line? Looks like very dark magic to me.