Skip to content

Instantly share code, notes, and snippets.

@Chandler
Last active August 29, 2015 14:04
Show Gist options
  • Save Chandler/0808df5ac6c6621e8de0 to your computer and use it in GitHub Desktop.
Save Chandler/0808df5ac6c6621e8de0 to your computer and use it in GitHub Desktop.
def sideEffect() {
//increment hadoop counter
}
val list = List(Some("a"),Some("b"),None, Some("e"), None)
val filtered = list.flatMap { x =>
if(x.isEmpty) sideEffect()
x
}
filtered
// res36: List[java.lang.String] = List(a, b, e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment