Concatenation: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Nightname
No edit summary
>Nightname
No edit summary
(No difference)

Revision as of 18:32, 28 March 2012

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