Skip to content

Instantly share code, notes, and snippets.

@sliskiCode
Last active December 6, 2017 22:53
Show Gist options
  • Save sliskiCode/565131f5da03228b4f9c10f908d15b73 to your computer and use it in GitHub Desktop.
Save sliskiCode/565131f5da03228b4f9c10f908d15b73 to your computer and use it in GitHub Desktop.
6 magic sugars that can make your Kotlin codebase happier #16
class MediaItemRenderer : Renderer {
override fun render(view: View, item: Item) = with(view) {
if (item !is MediaItem) {
throw AssertionError("Item is not an instance of MediaItem")
}
showMedia(item.media)
reset()
}
}
class IconItemRenderer : Renderer {
override fun render(view: View, item: Item) = with(view) {
if (item !is IconItem) {
throw AssertionError("Item is not an instance of IconItem")
}
showIcon(item.icon)
reset()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment