What is the different between let and var in swift ?

In a new programming language  Swift, You can declare constant and variable using the let and var keyword. constant and variable declare with particular name and its value.



Different between let and var :

Let :
 let keyword in swift is used to declare constant value and immutable can never be changed once defined.

let name ="Kirit" 

after you can change name = "Modi" then you got compiler error. So declare value of its only one time using let keyword.

Var :
 var keyword is mutable in swift is used to declare variant value, That value can change at run time. it means can change it too many time.

var name = "Kirit" 

You can changed name = "Modi" then successfully updated value of variable.


Thanks :
What is the different between let and var in swift ? What is the different between let and var in swift ? Reviewed by KIRIT MODI on 18:49:00 Rating: 5

No comments:

Powered by Blogger.