Str

String

A string is a sequence of characters used to represent text. Names, messages, and user input are all stored as strings.

For a broader introduction to data types including strings, see Data Types.

Creating a String#

A string is written between quotation marks.

string name = "Odds and Evens";
name = "Odds and Evens"
let name = "Odds and Evens";

String Interpolation#

String interpolation lets you embed the value of a variable directly inside a string. Instead of building the string in pieces, you write the whole message in one place with placeholders for the variable values.