【发布时间】:2017-10-30 20:00:24
【问题描述】:
Swift 有这个方便的语法:
enum Foo {
case bar
case baz
}
func hoge(foo: Foo) {
}
hoge(foo: .bar) // This
在enums 以外的地方镜像:
struct Qux {
static let `default` = Qux()
}
func hoge(qux: Qux) {
}
hoge(qux: .default) // This
我不确定在对话/门票中如何称呼它。也许是“类型推断的点语法”?我不确定。 这种语法有正式名称吗?如果有,它是什么?
【问题讨论】:
-
enum Foo { case .bar }无法编译