Back to Intellij Community

ReplaceReadLineWithReadln

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceReadLineWithReadln.html

2025.3-rc-2408 B
Original Source

Reports calls to readLine() that can be replaced with readln() or readlnOrNull().

Using corresponding functions makes your code simpler.

The quick-fix replaces readLine()!! with readln() and readLine() with readlnOrNull().

Examples:

val x = readLine()!!
    val y = readLine()?.length

After the quick-fix is applied:

val x = readln()
    val y = readlnOrNull()?.length