Collection has a property called lazy which is very useful for performance reasons. From the docs, lazy:
A view onto this collection that provides lazy implementations of normally eager operations, such as map and filter.
Array implements Collection, so if you have a large array, you can do this:
var veryLargeArray = [1, 20, 30, 4, 55]
var c = veryLargeArray.lazy.map { $0 * $0 }
c[1] //Random access without processing the entire array
It's a tiny, localized change to your code that, under the right circumstances, can have incredible performance improvements. Since lazy is a property of the Collection protocol, you can use it with all collection types that implement it, including Dictionary and Set.
.
.