How to use constant in Swift

3 Answers

0 votes
let constN = 987

print(constN)

// constN = 100 // error: cannot assign to value: 'constN' is a 'let' constant



/*
run:

987

*/

 



answered Feb 8, 2021 by avibootz
0 votes
let constN:Float = 3.1415926535897

print(constN)




/*
run:

3.1415927

*/

 



answered Feb 8, 2021 by avibootz
0 votes
let constS = "swift"

print(constS)

// constS = "c++" // error: cannot assign to value: 'constS' is a 'let' constant




/*
run:

swift

*/

 



answered Feb 8, 2021 by avibootz
...