Variable in swift

Viewed 46

Is it safe to say that there are two types of variable in Swift ?

  1. variable
  2. Constant

Can constant be reffered to as a type of variable?

I ask this question because in programming world, variable can be define as data container (way to hold and store data).

Need more light shed on this to clear all doubt.

1 Answers

In Swift, a constant and a variable are two different types of data containers that are declared with different keywords, let and var respectively. So a constant is not a type of variable.

A variable is a data container whose value can be changed. A constant is a data container whose value is set once and can never be changed.

Related