Constants and variables are used for temporary storage of values. By saving the result of the process, you can reuse it in the subsequent process. Variables can be reassigned, but constants cannot be reassigned once.
The variable is var and the constant is let.
var variable name:Model name
let variable name:Model name
Substitute 3 for the variable names a and b. Declare it as an Int type.
var a:Int=3
let b:Int=3
Then substitute 1 for a and b.
a=1//1
b=1//Compile error
As you can see from the result, it is possible to substitute 1 for a, but not for b.
Recommended Posts