Mixing operand types the type of the left operand dictates the behavior.

suggest change

For Addition

"4" + 2         # Gives "42"
4 + "2"         # Gives 6
1,2,3 + "Hello" # Gives 1,2,3,"Hello"
"Hello" + 1,2,3 # Gives "Hello1 2 3"

For Multiplication

"3" * 2   # Gives "33"
2 * "3"   # Gives 6
1,2,3 * 2 # Gives 1,2,3,1,2,3
2 * 1,2,3 # Gives an error op_Multiply is missing

The impact may have hidden consequences on comparison operators :

$a = Read-Host "Enter a number"
Enter a numberĀ : 33
$a -gt 5
False

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents