1

I already searched here and I hope, I didn't miss any post, but I couldn't find a answer for this question:

I want to extend an array of a specific type, in my case only an array of [String].

How do I do that?

extension [String] { ...

doesn't work.

Lupurus
  • 3,618
  • 2
  • 29
  • 59
  • Possible duplicate of http://stackoverflow.com/questions/24938948/array-extension-to-remove-object-by-value. From the top-voted answer: *"You cannot write a method on a generic type that is more restrictive on the template. ... Your best bet is to make it a function that accepts the array as an argument"* – Martin R Apr 24 '15 at 20:52
  • Thanks for your fast answer. Is there any workaround? Using a function would surely work, but it isn't that nice as extending the array ;) – Lupurus Apr 24 '15 at 20:56
  • As far as I know, no. But have a look at the various answers to that question and also the questions in the "Related" section. – Martin R Apr 24 '15 at 20:59

0 Answers0