Skip to content

Instantly share code, notes, and snippets.

@gervasiocaj
Last active February 17, 2020 20:12
Show Gist options
  • Save gervasiocaj/aa093b0685859c87a72c68ed74d001e5 to your computer and use it in GitHub Desktop.
Save gervasiocaj/aa093b0685859c87a72c68ed74d001e5 to your computer and use it in GitHub Desktop.
Implementation of the Bonding comic featured in xkcd blog https://xkcd.com/1188
class Ball: Throwable()
class P(var target: P?) {
fun aim(ball: Ball) {
try {
throw ball
} catch (b: Ball) {
target?.aim(b)
}
}
}
fun main() {
val parent = P(null)
val child = P(parent)
parent.target = child
parent.aim(Ball())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment