Table of contents
The term concatenation means the joining of two things.
Concatenation is the operation of connecting two strings in programming.
Use Cases and Examples
Concatenation is used mainly in the presentation of data on a user interface.
For example, you typically provide your name in an online form as separate fields, i.e., first and last name.
However, when it comes to displaying them say, on a receipt, the software will stack them side by side with a space in between.
In psuedo code this will look something like this
first_name+ space + last_name.
01: firstName = 'John'; 02: lastName = 'Doe'; 03: fullName = firstName+' '+lastName; 04: console.log(fullName); //John Doe
Most programming languages use the
+ symbol for concatenation as well. But for example, PHP uses
. for this.
In addition to this approach, some programming languages provide special functions for this as well. These functions allow for complex concatenations.
An example is PHPs
sprintf [↗] function.
As a developer, you will find yourself doing a lot of concatenations.
Depending on the programming language in use, you will have to be careful because, for most languages, the same
+ symbol also means addition.
If the values to concatenate turn out to be numbers, they might be summed up instead. You need an understanding of casting [→] to know how to deal with such cases.
Here is another article you might like 😊 "What Is Concurrency?"