I'm using Coldfusion. I want to concatenate two strings into the same struct key, but I keep getting an error of "can't convert x into a boolean."
For example:
<cfset myStruct.string1 = nodes[1].string1.XmlText> <cfset mystruct.string2 = nodes[1].string2.XmlText>
Neither of the following works
<cfset myStruct.concatendatedSring = nodes[1].string1.XmlText AND nodes[1].string2.XmlText> <cfset myStruct.concatendatedSring = myStruct.string1 AND myStruct.string2>
Why does neither method work?
You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
C++ '+' operator for String Concatenation C++ '+' operator can be used to concatenate two strings easily. The '+' operator adds the two input strings and returns a new string that contains the concatenated string.
Concatenating strings would only require a + between the strings, but concatenating chars using + will change the value of the char into ascii and hence giving a numerical output.
&
is the string concat operator, AND
and &&
are boolean operators.
<cfset myStruct.concatendatedSring = myStruct.string1 & myStruct.string2>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With