What is the difference between `let` and `var` in swift?

后端 未结 30 1324
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 11:09

What is the difference between let and var in Apple\'s Swift language?

In my understanding, it is a compiled language but it does not check

30条回答
  •  情深已故
    2020-11-22 11:47

    Let is an immutable variable, meaning that it cannot be changed, other languages call this a constant. In C++ it you can define it as const.

    Var is a mutable variable, meaning that it can be changed. In C++ (2011 version update), it is the same as using auto, though swift allows for more flexibility in the usage. This is the more well-known variable type to beginners.

提交回复
热议问题