How Strings and Substrings work in Swift

Suragch
5 min readDec 29, 2018

This is a synthesis of two answers I wrote on Stack Overflow (here and here).

All of the following examples use

var str = "Hello, playground"

Strings and substrings

Strings have changed a lot over the Swift versions. As of Swift 4, when you get some substring from a String, you get a Substring type back…

--

--