Last active
February 17, 2020 20:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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