AFAIK everything is a string, it's just parsed prior to being processed. So it sees the 5, then characters it omits, same for the other string, so you are left with two numbers (which probably are processed as floats) which the + operator adds. Is that correct?
Numeric operators convert their arguments to numbers (according to well defined rules) before performing the operation. That's why "5apples"+ "7 orange" gives 12. Conversely, string operators convert their arguments to strings before the operations is performed.
In other words, regardless of the arguments, the operator automatically performs the necessary conversions according to what it expects.
because + is an operation for numbers, and yes, answer is correct, because 5 + 7 is 12
if you expected to see "5apples7 orange", in this case you should use concatenate operator "_"
write "5apples" _ "7 orange"
Thank you for your guidance . But "" its mentioned string . how to add a string ?
if you need add a string, you should concatenate it with operator _
+ converts all types to number, and doing arithmetical operator add
7_"" became "7"
+"5apples" became 5
Thank you Dmitry
Hi, Ponnumani. I've changed the title to closer to the question version.
AFAIK everything is a string, it's just parsed prior to being processed. So it sees the 5, then characters it omits, same for the other string, so you are left with two numbers (which probably are processed as floats) which the + operator adds. Is that correct?
Numeric operators convert their arguments to numbers (according to well defined rules) before performing the operation. That's why "5apples"+ "7 orange" gives 12.
Conversely, string operators convert their arguments to strings before the operations is performed.
In other words, regardless of the arguments, the operator automatically performs the necessary conversions according to what it expects.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue