class ViewController: UIViewController {
var intValue = 1 //This is a property, but it is variable. That means its value can be changed in future.
let doubleValue = 3.14 // This is a property too, but it is constant. That means its value can't be change
// Both `intValue` & `doubleValue` will be in memory till ViewController's existence.
}
IN YOUR CASE:
let elementList = ["Carbon", "Gold", "Chlorine", "Sodium"]
elementList
is a array of String
, since let
keyword denotes that it is a constant property
To Add a constant property called elementList to ViewController.swift and initialize it. IT WOULD LOOK SOMETHING LIKE THIS
class ViewController: UIViewController {
let elementList = ["Carbon", "Gold", "Chlorine", "Sodium"]
//..
}