Online Snippets

How to declare a constant in swift

Constants are varibles that values cannot be changed during the script.


let constant_Name = <value>;

Below is a simple example.

// Integer constant
let a : Int = 3

// String constant
let b : String = "My Fisrt string"

//Integer constant - no need to declare a type,

var c = 5