Swift: Capitalize and de-capitalize a list
By somaria
2022-10-28
import Cocoa /* Create a 3 letter list of the first 6 months of the year */ let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] /* de-capitalize the list of months */ let lowerMonths = months.map { $0.lowercased() } /* print the list of months */ print(lowerMonths) /* Capitalize the first letter of the list of months */ let capitalizedMonths = months.map { $0.capitalized } /* print the list of months */ print(capitalizedMonths)

Output

["jan", "feb", "mar", "apr", "may", "jun"]

["Jan", "Feb", "Mar", "Apr", "May", "Jun"]