How exactly does the “let” keyword work in Swift?

后端 未结 6 867
时光说笑
时光说笑 2020-12-02 23:27

I\'ve read this simple explanation in the guide:

The value of a constant doesn’t need to be known at compile time, but you must assign it a value exa

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 23:46

    F# users will feel right at home with Swift's let keyword. :)

    In C# terms, you can think of "let" as "readonly var", if that construct was allowed, i.e.: an identifier that can only be bound at the point of declaration.

提交回复
热议问题