I converted some Java classes to kotlin and an "Assignments are not expressions, and only expressions are allowed in this context" error pops up when I try to run this code which worked fine in Java:
@Throws(IOException::class)
private fun readAll(rd: Reader): String {
val sb = StringBuilder()
var cp: Int
while ((cp = rd.read()) != -1) {
sb.append(cp.toChar())
}
return sb.toString()
}
The line causing the problem:
while ((cp = rd.read()) != -1)