swift string variable code example
Example 1: print string sqift
var str1 = "Hello, world"
print(str1)
Example 2: swift variable in a string
let x = 10
let string = "x equals \(x) and you can also put expressions here \(5*2)"
Example 3: declare empty string in swift
// Create a literal empty string
var emptyString = ""
// Create an optional string
var emptyVariable: String? // This allows this variable to have a null value, or nil in swift