Operators/Concatenation

From FizzFuzz

Jump to: navigation, search
Go back to Operators.

Concatenation is an operator performed on two characters and/or strings, converting them into a new string. Concatenation is indicated via the + operator (the plus sign), as a binary infix operator. The operation is associative but noncommutative.

Contents

Notation

α + β

Where one of α and β are either a char or string. FizzFuzz is coercive, so as long as one of one of α and β are character-based, the other will be correctly cast.

Assignment

Α += β
Α = Α + β

Where:

  • Α is a string. It can not be a char, as a char can only hold a single character.
  • β is a value modifying Α. It can be any data type that can be typecast as a string.

Example

char alpha = 'a';
string beta = "bcd";
bool theta = true;
float chi = 3.14159;
 
output << alpha + beta; // "Outputs "abcd".
output << beta + alpha; // "Outputs "bcda".
output << alpha + theta; // "Outputs "atrue".
output << beta + chi; // Outputs "bcd3.14159".
 
beta += chi;
output << beta; // Outputs "bcd3.14159".

See Also

Personal tools