0

Is it possible to do something like this at all in swift 4?

extension MyStruct where T: [Object] { }

I thought there has to be a way as this compiles:

let property = MyStruct<[Object]>()

My struct would than look like this:

struct MyStruct<T> { }

1 Answer 1

2

You want to restrict T to be equal to some type:

extension MyStruct where T == [Object] {

}

A constraint T: P would be used to restrict T to conform to (or inherit from) P.

Sign up to request clarification or add additional context in comments.

1 Comment

I am an idiot! yes :) ... forgot about the == :))) thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.