Skip to content

Instantly share code, notes, and snippets.

@bes89
Last active December 5, 2017 19:48
Show Gist options
  • Save bes89/6fd9c52d94a6bedafddd9845a3e6df80 to your computer and use it in GitHub Desktop.
Save bes89/6fd9c52d94a6bedafddd9845a3e6df80 to your computer and use it in GitHub Desktop.
job posting for a start-up looking for an android/kotlin dev
data class Skill(val description: String)
interface AwesomeGuy
interface AndroidGeek
interface TeamPlayer
object MateCrate {
val skills = mutableListOf<Skill>()
val members = mutableListOf<AwesomeGuy>()
val benefits = mutableListOf<String>()
fun beAwesome(andDoThis: () -> Unit) = andDoThis()
fun wilBeEvenMoreAwesome() = true
}
data class Person(val skills: Set<Skill>, val benefits: MutableList<String> = mutableListOf()) :
AwesomeGuy, TeamPlayer, AndroidGeek
val you: Person? = Person(setOf(Skill("..."), Skill("...")))
val bigBang = fun() {
MateCrate.let {
it.beAwesome {
you?.apply {
to(MateCrate)
when {
skills.isNotEmpty() &&
this is TeamPlayer &&
this is AwesomeGuy -> {
MateCrate.members.add(you)
with(you as AndroidGeek) {
it.wilBeEvenMoreAwesome()
fun yeah() {}
also {
you.benefits.addAll(MateCrate.benefits)
}
}
}
else -> run { print("sry") }
}
} ?: print("NPE caught")
}
}
}.invoke()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment