Tips for golfing in Swift What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help it excel in code-golf in certain applications?

Please post one tip per answer.
Ranges

One thing that is really helpful is creating ranges using the ... or ..&lt; operators

For example

array[0..&lt;n] //first n elements of array
array[k..&lt;n] //kth through nth elements of array
array[k...n] //kth through n-1 elements of array


So, to get the 2nd through 4th values of an array

let myArray = ["ab", "cd", "ef", "gh", "ij", "kl", "mn", "op"]
print(myArray[1..&lt;4]) //["cd", "ef", "gh"]


Practical Use

let a = [3, 1, 4, 1, 5, 9]


Using

for v in a[0...3]{print(v)}


Is 8 bytes shorter than

for n in 0...3{let v=a[n];print(v)}