What is the Swift syntax “ .bar” called?

后端 未结 2 2049
孤独总比滥情好
孤独总比滥情好 2020-12-11 20:01

Swift has this handy syntax:

enum Foo {
    case bar
    case baz
}


func hoge(foo: Foo) {
}


hoge(foo: .bar) //          


        
2条回答
  •  庸人自扰
    2020-12-11 20:29

    From Apple's Swift book:

    The values defined in an enumeration (such as north, south, east, and west) are its enumeration cases.

提交回复
热议问题