Concatenation: Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>PurpleKiwi Added link to table.concat |
>Nightname No edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
To quote Wikipedia: | |||
== | <blockquote cite="https://en.wikipedia.org/w/index.php?title=Concatenation&oldid=483997444"> | ||
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".</blockquote> | |||
The string concatenation operator in Lua is denoted by two dots (..). Here is an example of concatenation that concatenates "snow" and "ball" : | |||
{{ | {{Code and output| | ||
print(" | |code=print("snow" .. "ball") | ||
|output=snowball | |||
}} | |||
That code will concatenate "snow" and "ball" and will print the result, <samp>snowball</samp>. | |||
Numbers can be concatenated to strings, too. In this case they are [[coercion|coerced]] into strings and then concatenated. For example, suppose you wanted to concatenate "Green bottles: " and 10: | |||
{{code and output | |||
print(" | |code=print("Green bottles: " .. 10) | ||
|output=Green bottles: 10 | |||
}} | |||
=== See also === | |||
*[[Function_Dump/Table_Manipulation#table.concat_.28table_.5B.2C_sep_.5B.2C_i_.5B.2C_j.5D.5D.5D.29|table.concat]] | |||
*[http://lua-users.org/wiki/StringsTutorial Concatenation] | |||
*[https://en.wikipedia.org/wiki/Concatenation Wikipedia: Concatenation] | |||
[[Category:Scripting_Tutorials]] | [[Category:Scripting_Tutorials]] | ||
Latest 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" :
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: