Is there a string concatenation shortcut in PowerShell?

powershell, powershell-2.0

Solution

You actually have the operator backwards. It should be `+=`, not `=+`:

$string = "Hello"
$string += " there"

Below is a demonstration:

PS > $string = "Hello"
PS > $string
Hello
PS > $string += " there"
PS > $string
Hello there
PS >

However, that is about the quickest/shortest solution you can get to do what you want.

Problem

Like with numerics? For example, ``` $string = "Hello" $string =+ " there" ``` In Perl you can do ``` my $string = "hello" $string .= " there" ``` It seems a bit verbose to have to do ``` $string = $string + " there" ``` or ``` $string = "$string there" ```

Original source

Related problems