Returns an array containing the results of mapping the given closure over the sequence’s elements.
SDK
- Xcode 11.0+
Framework
- Swift Standard Library
Declaration
Parameters
transform
A mapping closure.
transform
accepts an element of this sequence as its parameter and returns a transformed value of the same or of a different type.
Return Value
An array containing the transformed elements of this sequence.
Discussion
In this example, map
is used first to convert the names in the array to lowercase strings and then to count their characters.