Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 413
Mohamad Avatar asked Sep 01 '10 22:09

Mohamad


People also ask

Which is the correct way to concatenate 2 strings?

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.

How do you concatenate characters in C++?

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.

Can we concatenate string and character?

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.


1 Answers

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

<cfset myStruct.concatendatedSring = myStruct.string1 & myStruct.string2> 
like image 84
Henry Avatar answered Sep 21 '22 03:09

Henry