I am trying to create a mathematical expression using Enumeration in Swift. This enumeration can be a constant with an associated value of type ComplexNumber (simple structure). It can also be a square root expression with a recursive associated value. For example, I want to be able to store sqrt (sqrt (1 + 2i)) in an enumeration.
enum Expression {
case Sqrt(Expression)
case Constant(ComplexNumber)
}
Xcode (6 beta 2) will work immediately. What is the problem? From what I read in the Swift tutorial about related values, this should work.
source
share