0 votes
in Swift by
What is the difference between Let and Var in swift?

1 Answer

0 votes
by
In swift language, we can declare a constant and variable using Let and Var keyword.

(i) Let: Let keyword is immutable, it’s used to declare a constant variable, and the constant variable cannot be changed once they are initialized.

For Example: let myAge = 25

We cannot change the value of age, you can declare the constant value of it only once using the let keyword.

(ii) Var: Var keyword is mutable, and is used to declare a variant variable. These variant variables can change the run time.

For Example:

var myName = “Dell”

we can change the value of name = “Apple”.

Related questions

0 votes
asked Nov 8, 2022 in Swift by SakshiSharma
0 votes
0 votes
asked Nov 7, 2022 in Swift by Robin
...