0

I've look around and haven't see anyone else who is having this problem (though it might be I'm just searching the wrong terms). If I have a simple generic class like:

class Foo<S> {
    var values:[S]

    init(values:S...) {
        self.values = values
    }

}

and I want to create a subclass:

class Bar<S>: Foo<S> {
    override init(values:S...) {
        super.init(values: values)
    }
}

For the Bar class I get the error:

error: cannot convert value of type '[S]' to expected argument type '[_]'

Does anyone know if this is either expected before and how to fix this, or if this is a bug that should be reported?

Abe Schneider
  • 977
  • 1
  • 11
  • 23
  • 1
    This has indeed been answered before :) but the error message is not obvious. Inside the init method of class B, `values` is an *array* which cannot be passed as a *variable argument list.* You have to add another `init(values:[S])` method to the superclass. – Martin R May 28 '16 at 14:09
  • Ah, okay. That makes a lot of sense. I suspected I was missing something obvious. Thanks! – Abe Schneider May 28 '16 at 14:11

0 Answers0