The problem is, that the array will clear itself after leaving the "if" function, and I want to keep it saved, even in the while loop.
while (letters != correct) {
var missedl = arrayListOf("")
if (word.contains(input)) {
println("Missed letters: $missedl")
} else {
missedl.add(input)
println("Missed letters: $missedl")
}
}
This doesn't work either:
while (letters != correct) {
var missedl = arrayListOf("")
missedl.add(p)
var p = if (word.contains(input)) {
println("Missed letters: $missedl")
} else {
input
println("Missed letters: $missedl")
}
}
Aucun commentaire:
Enregistrer un commentaire