vendredi 31 juillet 2015

Why do I get the 'Use of unresolved identifier' error when writing this code in Swift?

I have the following code:

let FOO = true
if (FOO) {
    let BAR = "Off"
} else {
    let BAR = "On"
}
print(BAR)

My problem that is the line that says print(BAR) returns the error:

Use of unresolved identifier 'BAR'

From what I can see, there is no reason that this code shouldn't compile is there? The constant BAR will always be created so can always be printed to the console.

Aucun commentaire:

Enregistrer un commentaire