What are strings?

350 views

There is a recent tweet in which a lady said 1+2=12.

Obviously that is wrong but everyone keeps saying “it’s wrong unless we are talking about strings”

What are strings?

Edit: thank you all for explaining:) have a cookie 🍪 and a wonderful day

In: 6

10 Answers

Anonymous 0 Comments

In this context, they’re talking about the data type used in programming used to store pieces of text. For instance, in most programming languages,

“hello, world”

would be treated as representing an object containing the text “hello, world”. Some programming languages let you use the “+” symbol to represent string concatenation (attaching) as well as addition.

“meat” + “gun” == “meatgun”

So in the twitter example, it wouldn’t be adding the numbers 1 and 2 to get 3, but rather sticking the strings “1” and “2” together to get “12”

You are viewing 1 out of 10 answers, click here to view all answers.