Currently I have a when block like this:
val foo = getStringFromBar()
when {
foo == "SOMETHING" -> { /*do stuff*/ }
foo == "SOMETHING ELSE" -> { /*do other stuff*/ }
foo.contains("SUBSTRING") -> { /*do other other stuff*/ }
else -> { /*do last resort stuff*/ }
}
Is there any way to simplify this to something like this:
val foo = getStringFromBar()
when (foo) {
"SOMETHING" -> { /*do stuff*/ }
"SOMETHING ELSE" -> { /*do other stuff*/ }
.contains("SUBSTRING") -> { /*do other other stuff*/ } // This does not work
else -> { /*do last resort stuff*/ }
}