mardi 4 août 2015

Swift if statement not returning value

In the block of Code below, String(quakeTsunamiWarning) isn't returning with any response, and is giving the error Use of Unresolved Identifier 'quakeTsunamiWarning'

I'd like to apologise in advance if something is obviously wrong or blatantly obvious, but i'm still rather new when it comes to Programming with Swift. (Going off free tutorials I can find on Google here, as I don't have the funds to pay for a course or paid tutorial)

var quakeTsunami = 0

func newQuake() -> Void {
    if quakeTsunami == 0 {
        var quakeTsunamiWarning = "False"
    } else if quakeTsunami == 1 {
        var quakeTsunamiWarning = "True"
    } else {
        var quakeTsunamiWarning = "N/A"
    }

    println(String(quakeTsunamiWarning))
}

I've removed all the other code from the example, for sake of keeping this post relatively small, but here's a link to a gist if you want the full document. http://ift.tt/1IoA3ho

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire