Hello, I’m quite newbie with kotlin.
Just tryin to make program that ask to type a word and count them. There is many ways of course to do program, but I’m mostly stuck with char input… How to make program like that expect char x to quit loop?? What’s syntax ? For numbers it’s like
while (line != -1), but == x, =‘x’ !=‘x’ isnt allowed.
fun main(args : Array) {
val numbers = mutableSetOf()
var line = readLine().toString()
while (line is Char("x")) {
println("Type a word (Type x to exit)")
line = readLine()!!.toString()!!
if (line is Char(x))
numbers.add(line)
}
val total =numbers.count()
println("You typed $total words")
}