Restrictions

suggest change

A where clause can restrict a method on a generic type. Swift 2 spelled this constraint StringLiteralConvertible and used uppercaseString. The body only works for String, and Swift 3 and later use uppercased().

extension Array where Element == String {
  func toUpperCase() -> [String] {
      var result = [String]()
      for value in self {
          result.append(value.uppercased())
      }
      return result
  }
}

Example of use

let array = ["a","b","c"]
let resultado = array.toUpperCase()

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents