Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They may not be recursive however


You can work around that using a "Box" type that wraps a value in a reference:

    class Box<T> {
        var contents : T
        init(_ initialContents : T) {
            contents = initialContents
        }
    }

    enum BinaryTree {
        case Leaf
        case Branch(Box<BinaryTree>, Box<BinaryTree>)
    }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: