Preview:
fun main() {
    println("Enter a nullable integer:")
    val input = readLine()
    val number: Int? = input?.toIntOrNull()
    if (number != null) {
        println("The square of the number is: ${number * number}")
    } else {
        println("Input is null or not a valid integer.")
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter