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

Explain some design patterns which we normally use during the app development.

483


What are type methods in swift?

439


How proficient are you in objective-c and swift? Can you briefly describe their differences?

680


What is tuple? How to create a tuple in swift?

496


What is static in swift?

507






Explain the adapter and memento pattern?

520


What is the meaning of question mark "?" In swift?

499


What is difference between weak and strong in swift?

487


What is an optional in swift?

444


What is an attribute in swift?

513


Explain functions?

500


What is the difference between swift and objective c?

471


Are arrays structs in swift?

435


Is swift compiled or interpreted?

505


Explain what is half-open range operator?

462