Restrictions

suggest change

It is possible to write a method on a generic type that is more restrictive using where sentence.

extension Array where Element: StringLiteralConvertible {
  func toUpperCase() -> [String] {
      var result = [String]()
      for value in self {
          result.append(String(value).uppercaseString)
      }
      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