Concatenation

From Legacy Roblox Wiki
Revision as of 18:32, 28 March 2012 by >Nightname
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

To quote Wikipedia:

In computer programming, string concatenation is the operation of joining two character strings end-to-end. For example, the strings "snow" and "ball" may be concatenated to give "snowball".

The string concatenation operator in Lua is denoted by two dots (..). Here is an example of concatenation that concatenates "snow" and "ball" :

print("snow" .. "ball")
snowball

That code will concatenate "snow" and "ball" and will print the result, snowball.

Numbers can be concatenated to strings, too. In this case they are coerced into strings and then concatenated. For example, suppose you wanted to concatenate "Green bottles: " and 10:

print("Green bottles: " .. 10)
Green bottles: 10


See also