0 votes
68 views
asked in Swift by (3.1k points)
Hi All

  What is String Interpolation in swift?

1 Answer

0 votes
answered by (4k points)

Hi Jonathan

String interpolation is a way to construct a new String value from a mix of constants, variables, literals, and expressions by including their values inside a string literal. Each item that you insert into the string literal is wrapped in a pair of parentheses, prefixed by a backslash:

  • let multiplier = 3
  • let message = "\(multiplier) times 2.5 is \(Double(multiplier) * 2.5)"
  • // message is "3 times 2.5 is 7.5"

Categories

...