Swift 5.1: Strings Cheat Sheet

// Using a string literal as an initial value for
// a constant or variable
let helloWorld = "Hello, World!"
// Using a multiline string literal to span
// over several Lines
let helloWorldProgram = """
A "Hello, World!" program generally is a computer program that outputs or displays the message "Hello, World!"
"""
// Empty string
let emptyString = "" // Using string Literal
// Initializer syntax
let anotherEmptyString = String()
// Mutating a string
var mutableString = "Swift"
mutableString += " is awesome!"
// String interpolation
// Interpolating a Double
print("The value is (double)”)
// Interpolating a String
print("This is my opinion: (mutableString)”)

Leave a Reply

Your email address will not be published. Required fields are marked *