question about self-refer in swift structure

Hello,

I have a question about self-refer in using structure in swift. I want to use structure to implement Node. so I wrote code like this;

public struct Node {
    var Data:Int = 0
    var next:Node?
}

I've got an error message says: Value type 'Node' cannot have a stored property that recursively contains it.

the question is: self-refer is impossible in swift? if someone give me an advice about this, I'd be very appreciated.

thanks,

c00012

Value type 'Node' cannot have a stored property that recursively contains it.

The error message tells you it is not possible with a value type (a struct).

It is possible with a Reference type. Use a class instead:

class Node {
    var Data:Int = 0
    var next:Node?
}
question about self-refer in swift structure
 
 
Q