定義済みの String 値を文字列リテラルとしてコードに含めることができます。文字列リテラルは、ダブルクオート ("") で囲まれた、固定された一連のテキスト文字です。

定数または変数の初期値として文字列リテラルを使用します。

let someString = "Some string literal value"

Swift は、定数 someString が文字列リテラル値で初期されているため、String 型と推論します。

NOTE
文字列リテラルでの特別な文字の使用についての情報は、Special Characters in String Literals を確認してください。

Portions of this page are translations based on work created and shared by Apple and used according to terms described in the Creative Commons Attribution 4.0 International License.