Time for action – Concatenation
The good news is we've been using concatenation for awhile now, in our log lines. The two operators are the at symbol (@
) and the dollar sign ($
). The only difference between the two is whether or not we want a space in between the strings we're joining.
Let's write some code.
var string String1, String2, AtSign, DollarSign; function PostBeginPlay() { AtSign = String1 @ String2; DollarSign = String1 $ String2; 'log("At sign:" @ AtSign); 'log("Dollar sign:" @ DollarSign); } defaultproperties { String1="This is" String2="a test." }
Looking at the log shows us the minor difference between the two:
[0007.77] ScriptLog: At sign: This is a test. [0007.77] ScriptLog: Dollar sign: This isa test.
The choice between them is as simple as the space between the joined strings.
The concatenation operators can also be used with equal signs to shorten the code and get rid of the need for extra variables. The
@
code could also be written like this:var...