mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We haven't fully updated references to union cases, and enums still are not their own thing yet, but "oneof" is gone. Long live "union"! Swift SVN r6783
31 lines
384 B
Swift
31 lines
384 B
Swift
union Basic {
|
|
case Untyped
|
|
case HasType(Int)
|
|
|
|
constructor() {
|
|
this = .Untyped
|
|
}
|
|
func doSomething() {}
|
|
}
|
|
|
|
union Generic<A> {
|
|
case Left(A)
|
|
case Right(A)
|
|
}
|
|
|
|
|
|
protocol Computable {
|
|
func compute()
|
|
}
|
|
|
|
union Lazy<T> : Computable {
|
|
case Thunk(() -> T)
|
|
case Value(T)
|
|
|
|
func compute() {
|
|
// if (this ~= .Thunk(var fn)) {
|
|
// this = .Value(fn())
|
|
// }
|
|
}
|
|
}
|