Learn Lua · First steps · Lesson 3 of 4
Text
Text in Lua is called a string: characters inside double quotes, like "Ada". ..
(two dots) joins strings end to end, and # counts the characters in one:
"Print" .. "Shop" --> "PrintShop"
#"Ada" --> 3Lua adds nothing between the strings it joins. To get a space, put one inside the quotes:
"Hello, " .. "Ada" gives "Hello, Ada". Numbers join too, and become text:
"Order " .. 42 --> "Order 42"\n inside quotes starts a new line, so "one\ntwo" is two lines of text.
Steps
- Set
nameto the full name:first, a space, thenlast. - Return
letters: how many characters the full name has, counting the space. - Return
lines:firstandlaston two separate lines.
Show a hint
Join three strings for the name: first, " " and last. # works on a name that
holds a string, as well as on a string in quotes.