Skip to content

Instantly share code, notes, and snippets.

@matteo-grella
Created May 12, 2019 22:05
Show Gist options
  • Save matteo-grella/f7fd414db1947e7204f5bf06fe8958c0 to your computer and use it in GitHub Desktop.
Save matteo-grella/f7fd414db1947e7204f5bf06fe8958c0 to your computer and use it in GitHub Desktop.
Return the list if it is not empty, otherwise null
/**
* Return the list if it is not empty, otherwise null
*/
private fun <T>List<T>.notEmptyOrNull(): List<T>? = if (this.isEmpty()) null else this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment