Skip to content
Justice Tech School

Strings

Strings are Unicode aware. Use count, hasPrefix, contains, split and uppercased.

Example
let s = "Hello, Swift"
print(s.count, s.uppercased(), s.hasPrefix("Hello"))
print(s.contains("Swift"), s.split(separator: ",").map(String.init))
print(s.replacingOccurrences(of: "l", with: "L"))
print(String(s.reversed()))

Exercise

Prefix test.

s.("He")

Quiz Test

Why no integer index on String?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.