why cant i reference a struct in the same struct type

155 views Asked by At

I have a struct the has a property of the same type. I'm getting an error

Value type '' cannot have a stored property that references itself

But this is not a reference to self. It's just a reference to a value of the same type.

If i change it to a class everything works (i need it to be a struct)

code:

public struct MockData {
    var data1: Int!
    var data2: String!
    var data3: MockData?
}

Why is this not compiling, what is the problem?

Thanks

0

There are 0 answers