Skip to content

Instantly share code, notes, and snippets.

@maartenl
Last active September 7, 2022 13:07
Show Gist options
  • Save maartenl/ba132afd423e3678e64af5e3817e25f9 to your computer and use it in GitHub Desktop.
Save maartenl/ba132afd423e3678e64af5e3817e25f9 to your computer and use it in GitHub Desktop.
use ?.<operator> to fix the problem
/**
* use "?.let" to create a lambda in which we're sure there's no problem.
* Is a very nice solution, if possible.
*/
@Test
fun mutablePropertyCouldHaveChanged4() {
name?.let { assertThat(it.length).isNotZero() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment