0

How to declare a string type ?

I am unable to understand the difference between a constant data type and a string data type.

10th Nov 2016, 9:34 AM
Ankit Arora
Ankit Arora - avatar
2 Answers
+ 1
A constant is not a type of data but it declares that a certain variable's value can't be changed after its first set. To declare a constant use the "let" keyword: let PI: Double = 3.14 let MY_NAME: String = "Gleb Golov" See that I annotate different constants with different types. Here are few very variables (their value can be changed, assigned to another value): var year: Int = 2016 var actualPresidentName: String = "Donald Trump" // Jump 4 years! year += 4 // Now it's 2021 // Time to change presidency! actualPresidentName = "Mickey Mouse"
12th Nov 2016, 9:41 PM
Gleb Golov
Gleb Golov - avatar
0
Mickey Mouse nice one , thanx Gleb
13th Nov 2016, 2:26 AM
Ankit Arora
Ankit Arora - avatar