1 string interpolation is a new way to build a string that contains constants, variables, literals, and expressions. Each entry of the string literal that you insert is wrapped in parentheses prefixed with a backslash:2Let multiplier =33Let message ="\ (multiplier) times 2.5 is \ (Double (multiplier) * 2.5)"4 //message is ' 3 times 2.5 is 7.5 '5 In The example above, multiplier as \ (multiplier) is inserted into a string literal. When you create a string to perform an interpolation calculation, this placeholder is replaced with the multiplier actual value. 6 7The value of multiplier also acts as part of the subsequent expression in the string. The expression evaluates to Double (multiplier) *2.5Value and the result (7.5) into the string. In this example, the expression is written as \ (Double (multiplier) *2.5) and is included in the string literal. 8Note: An expression written in parentheses in your interpolated string cannot contain non-escaped double quotation marks (") and a backslash (\), and cannot contain carriage returns or line feeds.
Swift string interpolation