I say “in effect” because a method that extracts a substring returns, in reality, a Substring instance. The Substring struct is an efficient way of pointing at part of some original String, rather than having to generate a new String. Thus, for example, when we call
s.dropFirst() on the string
"hello", the resulting Substring points at the
"ello" part of
"hello", which continues to exist; there is still only one string, and no new string storage memory is required.
Storage memory for string . Struct substring.
Share this highlighthttp://www.safaribooksonline.com/a/ios-11-programming/10354512/