0
How to declare a string type ?
I am unable to understand the difference between a constant data type and a string data type.
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"
0
Mickey Mouse nice one , thanx Gleb