I get that var
is for defining variables and let
is for defining constants.
My issue is, I am "able" to change my let
constants. For example, my test code takes in two inputs from the user, their name and emails. When a button is pressed, it will update two labels.
However, when I change the inputs, it will also change the labels. So why doesn't it crash or anything?
class ViewController: UIViewController {
@IBOutlet weak var emailInput: UITextField!
@IBOutlet weak var nameInput: UITextField!
@IBOutlet weak var label: UILabel!
@IBOutlet weak var label2: UILabel!
@IBAction func actionButton(_ sender: Any) {
let text = nameInput.text
let email = emailInput.text
label.text = text
label2.text = email
}
}