Swift struct type recursion

Viewed 6455

Why can't structs have recursive value types in Swift? Is this a temporary limit of the language or is it as intended?

I feel that the ability to declare a binary tree node as a struct with recursive types in it to be the most natural implementation.

struct TreeNode<E>{
var leftNode:TreeNode<E>
var rightNode:TreeNode<E>
var element:E
}
2 Answers
Related