3 ms·
On a side note, Swift's enum provides complete support for sum type.
by DaNmarner 12y ago
On a side note, Swift's enum provides complete support for sum type.
- dons 12y agoThey may not be recursive however
- panic 12y agoYou 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>) }