Search: in
Concatenation
Concatenation Encyclopedia
  Tutorials     Encyclopedia     Dictionary     Directory  
Concatenation Email this to a friend      Concatenation

Concatenation

In computer programming, concatenation is the operation of joining two character strings end to end. For example, the strings "foo" and "bar" may be concatenated to give "foobar". In programming languages, string concatenation is a binary operation usually accomplished by putting a concatenation operator between two strings (operands).

For example, the following expression uses the "+" symbol as the concatenation operator:

print "Hello " + "World";

Contents


Different languages

Different languages use different operators. Most languages use the "+" sign though several deviate from this norm.

Examples

Operator Language
+ ActionScript, BASIC, C++, C#, Java, JavaScript, Pascal, Python, Ruby, Windows PowerShell, SQL, GML
& Ada, AppleScript, VHDL, Visual Basic
. Perl (before version 6), PHP
~ Perl 6
// Fortran
REXX, SQL
$+ mIRC Scripting Language

For a more detailed comparison, please see the concatenation comparison article.

Programming conventions

Assignment

Many languages, such as PHP and JavaScript have a variant of the assignment operator that allows concatenation and assignment to a variable in one statement.

For example, in PHP and Perl:

//Example 1 (concatenation operator ".")
$var = "Hello ";
$var = $var . "World";

//Example 2 (combined assignment and concatenation ".=")
$var = "Hello ";
$var .= "World";

Both examples produce the same result.

Interpolation

Some languages, (such as Perl, PHP, and most Unix shells), support variable interpolation as an alternative form of string concatenation.

For example, in Perl, the concatenation syntax:

can be substituted with the string literal syntax:

since double quoted string literals in Perl indicate scalar variables with the dollar sign ($) scalar sigil.

See also

External links

bg:???????????? de:Konkatenation (Listen) es:Concatenación fr:Concaténation gl:Concatenación he:????? (???????) nl:Concatenatie pl:Konkatenacja ru:???????????? simple:Concatenation sv:Konkatenering tr:Concatenation zh:??





Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article



Related Links in Concatenation

Search for Concatenation in Tutorials
Search for Concatenation in Encyclopedia
Search for Concatenation in Dictionary
Search for Concatenation in Open Directory
Search for Concatenation in Store
Search for Concatenation in PriceGig


Help build the largest human-edited directory on the web.
Submit a Site - Open Directory Project - Become an Editor

Advertisement

Advertisement



Concatenation
Concatenation top Concatenation

Home - Add TutorGig to Your Site - Disclaimer

©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement