Numbers are one type of data that can be operated on. Let's explore another data type within the REPL. Take a set of quotes and put some text in it and hit ENTER:
"hello"
The REPL will print hello
back to you.
This is a string.
A string is a set of characters (letters and symbols) stringed together as one single piece of data.
This string is made of 9 characters:
"H-E-L-L-O"
Like numbers, there are operators to make strings play with each other.
The concatenate operator (..
) combines strings together:
"hello" .. "world"
What's the result? Notice that the resulting string has no space between the two words. If you wanted a space, you would have to put one in the quotes to be part of the operation:
"hello " .. "world"
You could even make a separate string with the space in it:
"hello" .. " " .. "world"
Strings can have any characters in them that you want.
"abc" .. "123"
"Япо́нский" .. "ロシア語!!"
- Try using an arithmetic operator on strings
"hello" / "world"
. What happens? - Try using the concatenate operator (
..
) on numbers (1 .. 1
).