What is difference between 'let' and 'var' declaration ?

Answer Posted / iosraj

constants are expressed with the ‘let’ keyword. So once assigned value can not be change, but assigned values using 'var' keyword can be change.

In terms of objective -c or compare with objective -c, 'var' is Mutable and 'let' is NonMutable.

let kMyConstant = 40

Or

let kMyConstant: Int = 40

var myString = "This is my string."

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an optional in swift?

438


What is forced unwrapping? Why is it potentially unsafe?

488


What is the swift main advantage?

438


What is a guard statement? What is the benefit of using guard statement in swift?

454


What is cocoa swift?

432






What is a deinitializer in swift?

587


Why swift is faster?

464


How do I add a bridging header in swift?

409


What is a lazy var in swift?

449


Is swift memory safe?

449


Explain grand central dispatch (gdc).

465


What is difference between weak and strong in swift?

474


What is property observer in swift?

472


What is data structure in swift?

447


What is abstract class in swift?

489