CONCATENATION
'Concatenation' is a standard operation in computer programming languages (a subset of formal language theory). It 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).
'''Normal concatenation, regarding programming'''
For example, the following expression uses the "+" symbol as the concatenation operator:
print "Hello " + "World";
which produces the output:
Hello World
| Contents |
| Different languages |
| Examples |
| Programming conventions |
| Assignment |
| Interpolation |
| External links |
Different languages
Main articles: Comparison of programming languages (strings)
Different languages use different operators. Most languages use the "+" sign though several deviate from this norm.
Examples
+ ;; BASIC, C++, Pascal, JavaScript, Java, Python, Ruby, C#
& ;; Ada, AppleScript, VHDL, Visual Basic
. ;; Perl (before version 6), PHP, and Maple (up to version 5)
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 and PHP), support 'variable interpolation' as an alternative form
of string concatenation.
For example, in Perl, the concatenation syntax:
my $stringVar;
$stringVar = "World";
print "Hello " . $stringVar;
can be substituted with the string literal syntax:
my $stringVar;
$stringVar = "World";
print "Hello $stringVar";
since double quoted string literals in Perl indicate scalar variables with
the sigil ($) character.
External links
★ Concatenation of languages (different from concatenation on strings)
This article provided by Wikipedia. To edit the contents of this article, click here for original source.
psst.. try this: add to faves

العربية
中国
Français
Deutsch
Ελληνική
हिन्दी
Italiano
日本語
Português
Русский
Español



