Skip to content

Instantly share code, notes, and snippets.

@lucapiccinelli
Last active July 20, 2019 05:42
Show Gist options
  • Save lucapiccinelli/cfddee0a63f8af96d35a04d3648448d2 to your computer and use it in GitHub Desktop.
Save lucapiccinelli/cfddee0a63f8af96d35a04d3648448d2 to your computer and use it in GitHub Desktop.
interface ArticleConsumer {
fun use(article: ItaArticle)
fun use(article: DeuArticle)
fun use(article: ArticleNotFound)
}
fun useAnArticle(article: Article) : String {
var x = ""
article.applyTo(object : ArticleConsumer {
override fun use(article: ItaArticle) {
x = article.itaData1
}
override fun use(article: DeuArticle) {
x = article.deuData1
}
override fun use(article: ArticleNotFound) {
x = "not found"
}
})
return x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment