Re:Sum Types in Go
by dons on Friday December 26, 2014 @04:33AM
(#8798535)
They may not be recursive however
[ Parent
| on HN ]
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>)
}