Tutorial by Examples: concatenate

Concatenate strings with the + operator to produce a new string: let name = "John" let surname = "Appleseed" let fullName = name + " " + surname // fullName is "John Appleseed" Append to a mutable string using the += compound assignment operator, or usi...
// Java: String joined = things.stream() .map(Object::toString) .collect(Collectors.joining(", ")); // Kotlin: val joined = things.joinToString() // ", " is used as separator, by default
The FOR XML PATH can be used for concatenating values into string. The example below concatenates values into a CSV string: DECLARE @DataSource TABLE ( [rowID] TINYINT ,[FirstName] NVARCHAR(32) ); INSERT INTO @DataSource ([rowID], [FirstName]) VALUES (1, 'Alex') ,(2, 'Peter') ...
$fruit1 = ['apples', 'pears']; $fruit2 = ['bananas', 'oranges']; $all_of_fruits = array_merge($fruit1, $fruit2); // now value of $all_of_fruits is [0 => 'apples', 1 => 'pears', 2 => 'bananas', 3 => 'oranges'] Note that array_merge will change numeric indexes, but overwrite string...
This is the primary purpose of cat. cat file1 file2 file3 > file_all cat can also be used similarly to concatenate files as part of a pipeline, e.g. cat file1 file2 file3 | grep foo
Variable declaration for examples: Collection<String> abc = Arrays.asList("a", "b", "c"); Collection<String> digits = Arrays.asList("1", "2", "3"); Collection<String> greekAbc = Arrays.asList("alpha", "be...
In (standard ANSI/ISO) SQL, the operator for string concatenation is ||. This syntax is supported by all major databases except SQL Server: SELECT 'Hello' || 'World' || '!'; --returns HelloWorld! Many databases support a CONCAT function to join strings: SELECT CONCAT('Hello', 'World'); --retur...
The simplest way to concatenate list1 and list2: merged = list1 + list2 zip returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables: alist = ['a1', 'a2', 'a3'] blist = ['b1', 'b2', 'b3'] for a, b in zip(alist, blist):...
One common use for the FOR XML function is to concatenate the values of multiple rows. Here's an example using the Customers table: SELECT STUFF( (SELECT ';' + Email FROM Customers where (Email is not null and Email <> '') ORDER BY Email ASC FOR XM...
Const string1 As String = "foo" Const string2 As String = "bar" Const string3 As String = "fizz" Dim concatenatedString As String 'Concatenate two strings concatenatedString = string1 & string2 'concatenatedString = "foobar" 'Concatenate three s...
'Declare and assign a string array Dim widgetNames(2) As String widgetNames(0) = "foo" widgetNames(1) = "bar" widgetNames(2) = "fizz" 'Concatenate with Join and separate each element with a 3-character string concatenatedString = VBA.Strings.Join(widgetNames, &q...
Concatenating strings using a StringBuilder can offer performance advantages over simple string concatenation using +. This is due to the way memory is allocated. Strings are reallocated with each concatenation, StringBuilders allocate memory in blocks only reallocating when the current block is e...
The System.String.Join method allows to concatenate all elements in a string array, using a specified separator between each element: string[] words = {"One", "Two", "Three", "Four"}; string singleString = String.Join(",", words); // singleString =...
The System.String.Join method allows to concatenate all elements in a string array, using a specified separator between each element: string[] words = {"One", "Two", "Three", "Four"}; string singleString = String.Join(",", words); // singleString =...
To concatenate the value of two or more variables into a single string and print it as the output, we need to make use of interpolation. The following Less code, #demo:after { @var1: Hello; @var2: World!!!; content: "@{var1} @{var2}"; } when compiled would set "Hello Wo...
Files compressed by gzip can be directly concatenated into larger gzipped files. cat file1.gz file2.gz file3.gz > combined.gz This is a property of gzip that is less efficient than concatenating the input files and gzipping the result: cat file1 file2 file3 | gzip > combined.gz A compl...
This is the typical approach for novice developers building SQL action queries. They are vulnerable to the Bobby Tables type SQL Injection attacks. Dim strSQL As String strSQL = "INSERT INTO Employees chrFirstName, chrLastName, chrPhone " _ & "VALUES ('" & M...
Two loops are concatenated if it’s possible to reach one after exiting the other on same path from entrance to exit. Sometimes these two loops are independent to each other. In those cases we can apply the design techniques specified as part of single loop testing. But if the iteration values in on...

Page 1 of 1