angryziber / kotlin-puzzlers

A collection of Kotlin Puzzlers
422 stars 58 forks source link

too softcore #31

Closed guai closed 5 years ago

guai commented 7 years ago

Your jpoint 2017 performance was more like introduction to kotlin and not puzzlers :)

Here is a couple of puzzlers for people who uses kotlin already:

operator fun Nothing?.not() = Unit
operator fun Unit.not() = null

var aaaa = null

fun main(args: Array<String>) {
    !!!!aaaa!!!! // will it work?
    (!!!!aaaa)!!!! // how about it?
    !!!!(aaaa!!!!) // or it?
}
operator fun Nothing?.not() = null

var aaaa = null

fun main(args: Array<String>) {
    !!!!aaaa!!!! // will it work?
    (!!!!aaaa)!!!! // how about it?
    !!!!(aaaa!!!!) // or it?
}
angryziber commented 7 years ago

@guai that was the point of the presentation at JPoint :-) I am now collecting a more hardcore ones for Kotlinconf, thanks!