String Literals

Quotation Marks

You can define a string either in double quotation marks ("This is a string") or in single quotation marks ('This is also a string').
They both behave the same.
The differences are, that you can use the other form inside a string literal without escaping it. In a declaration a string defined in single quotation marks are of type char, as long no type is specified. let exampleString = "Hello 'World' string"; // Hello 'World' string let exampleString2 = 'Hello "World" string'; // Hello "World" char array

Escaping

There are some characters that you can't write inside a string literals, this characters can be escaped with a backslash (\).

Escape Options

Examples

let exampleString = "Hello\"World!"; // Hello"World! let exampleString2 = "Hello\'World!"; // Hello'World! let exampleString3 = "Hello\\World!"; // Hello\World!