What are strings?

344 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 programming a string is a sequence of characters. It is basically text. The joke here is that 1 may be interpreted as either a string containing the single character ‘1’ or it could be the number. Some programming languages are known for often getting this wrong (JavaScript). When you add two strings together a lot of programming languages will concatenate the strings together. For example “Hello ” + “World!” would result in “Hello World!” when evaluated. And although no programming language is that bad at it you could imagine a programming language that interprets 1 + 2 as equal to “12”.

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