Skip to content

Instantly share code, notes, and snippets.

@stasimus
Last active October 9, 2018 21:18
Show Gist options
  • Save stasimus/26a75b2ab20db9c1bfcb24ac65e73ce8 to your computer and use it in GitHub Desktop.
Save stasimus/26a75b2ab20db9c1bfcb24ac65e73ce8 to your computer and use it in GitHub Desktop.
assertNull(p1?.flatMap { f -> p2.flatMap { s -> f + s } })
//or
val firstNullable = "param1".unit()?.flatMap { f -> null?.flatMap { f.plus(it) } }assertNull(firstNullable)
//or
val bothAreDefined = "param1".unit()?.flatMap { f -> "param2".unit()?.flatMap { f.plus(it) } }
assertEquals("param1param2", bothAreDefined)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment