MasterOnce
HomeBlogHow-To
3 min readJan 17, 2026
Swift

How to Use String Interpolation

Build readable strings with interpolation and formatting.

Steps

  1. Paste the code into a Swift file or playground.
  2. Run it once to verify the output.
  3. Adjust the inputs to match your use case.

Copy and paste

import Foundation

let city = "Paris"
let temperature = 18.5

let message = "It is (temperature) C in (city)."
print(message)

Notes

  • Keep functions small and focused for reuse.
  • Prefer safe APIs like optionals and guards.