How do I concatenate two strings and store them into the same struct key

Mohamad picture Mohamad · Sep 2, 2010 · Viewed 80k times · Source

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?

Answer

Henry picture Henry · Sep 2, 2010

& is the string concat operator, AND and && are boolean operators.

<cfset myStruct.concatendatedSring = myStruct.string1 & myStruct.string2>