Skip to content

Instantly share code, notes, and snippets.

@andremion
Last active August 20, 2018 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andremion/f7f3e77e5105cc39fd37761530fd2779 to your computer and use it in GitHub Desktop.
Save andremion/f7f3e77e5105cc39fd37761530fd2779 to your computer and use it in GitHub Desktop.
Extension function to filter and map items of a Collection
inline fun <reified T> Collection<*>.ofType(): Collection<T> = filter { it is T }.map { it as T }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment