powershelltypesoperatorsimplicit-conversionweak-typing

Why does order of operands matter when adding powershell strings and arrays?


In powershell, when I add string + array the result is a string, but when I add array + string the result is an array? Why is that?

string plus array vs array plus string


Solution

  • PowerShell converts the second operand to the type of the first operand (if it can).