Swift Language Extensions Restrictions

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


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 {
      return result

Example of use

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

Got any Swift Language Question?