Int { func _depth<T>(t: Tree<T>) -> Int { switch t { case .Empty: return 0 case .Leaf(let _): return 1 case .Node(let lhs, let rhs): return max(_depth(lhs), _depth(rhs)) } } return _depth(self) } }
from Objc with limitations • Call CoreFoundation types directly • C++ is not allowed (should be wrapped in Objc) • Subclassing Swift classes not allowed in Objc
{ case (0, 0): println("Point is at the origin") case (0...1, 0...1): println("I") case (-1...0, 0...1): println("II") case (-1...0, -1...0): println("III") case(0...1, -1...0): println("IV") default: println(“I don’t know.") }