How to declare a constant string in Swift

1 Answer

0 votes
import Foundation

let str = "abc"

// str = "xyz" // error: cannot assign to value: 'str' is a 'let' constant

print(str)



/*
run:

abc

*/

 



answered Jun 19, 2025 by avibootz
edited Jun 20, 2025 by avibootz

Related questions

...