Hi,
According to the Swift Blog (https://developer.apple.com/swift/blog/?id=22), the rule is that a let constant must be initialized before use (like a var), and that it may only be initialized, not reassigned or mutated after initialization.
let s = "foo"can be changed to
let s : String
s = "foo"But in a control flow statement which surrounds the above code, the compiler gives me an error that says "Cannot assign to value: 's' is a 'let' constant." For example,
if condition {
let s = "foo"
print(s)
}is OK, but
if condition {
let s : String
s = "foo"
print(s)
}is an error code.
Is my understanding is right?