Get the length of a string

 Problem

I have a String and want to calculate its length



 Recipe


// String literal
let s = "Hello world"

// Get the length of the string

let length = s.characters.count
print(length)

				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground