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”
Answer: It is a programmer joke.
The actual tweet is made by a US Political candidate which isn’t relevant to the answer but is necessary for the backstory.
In computer programming, a ‘string’ is basically a sequence of characters. I can have a string called str and have its value be whatever I want. The technicalities will differ based on language but as a high level concept that is what it means.
That tweet 1+2=12 was shared on multiple forums, including r/ProgrammerHumor
The + sign can be used to combine two strings. Like “foo” + “bar” can equal “foobar”. Just like that 1+2 can become 12 if you were to look at it like combining two strings together.
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”.
They’re speaking of strings in the computer science sense.
A string is any set of characters. Concatenating two strings — smushing together the two sets of characters — is frequently done in computer programs by using the “+” sign.
So if you have one string that is the character “A” and another that is the character “B” then when you concatenate them (smush them together) you get a single string of “AB.”
A + B = AB
Likewise if you had a string that was “E” and a string that was “LI5” when you concatenate them you get a single string of “ELI5.”
E + LI5 = ELI5
Likewise, if you have a string that consists of the character “1” and a string that consists of the character “2” then when you concatenate them you get “12.”
1 + 2 = 12
Basically it’s treating the equation as *characters* (“strings”) instead of *numbers*.
String is a programming data type. It’s basically a sentence of words, or alphanumeric characters that are intended to be read as a string, or straight characters, and does not have math operations performed on it. Integer is another data type, basically whole numbers that can be used for math. Another common data type is float, which is basically a number with a decimal. There are other data types, but those are the main 3 that you’ll ever use.
Ohh they mean programming. In programming languages we different types of variables. You can store information in a variable. If you want to store something numerical you are going to use something like integer format or float. Ints are intigers so if a=2 a is an integer. If a=2.5 a is a float. The computer handles these formas differently. Now strings are variables useful for storing text. If a=”yo yo yo Mr. White!” a is a string. Its a string of characters. If you want a number to be handled like a characters so no mathematical value assigned to it: a=”2″. a is a string containing the character 2.
You can do operations with strings like add them up. If you have two number like ints a=5, b=2 then a+b=7 it will add them up. But if you store characters in a string: a=”yo yo yo ” and b=”Mr. White!” then a+b will put the two strings together in order so a+b=”yo yo yo Mr. White!”. Similarly if a=”1″ and b=”2″ then a+b=”12″. Not the number 12 but the characters 1 and 2.
If you want to visualize it, imagine a piece of string of indeterminate length. Suspend it in the air so you can hang things on it.
To begin with, it is an empty string, or “”.
Then you thread a 2 onto it, and you’ve got a string of “2”.
Now you “add” a 1 by threading it on to the front of the string (or you could have started with the 1 and threaded the 2 onto the end of the string). Since you’ve added both letters to the string, the string now contains “12”.
Latest Answers