might sound like a completely silly question but w...
# announcements
a
might sound like a completely silly question but would there be some value in having an
always
in a when block? Like
Copy code
when (something) {
  FIRST_CASE -> doThis()
  SECOND_CASE -> doThat()
  else -> doSomethingElse()
  always -> andAlwaysDoThis()
}
I mean, sure, we can just write the always part outside of the when block but not when it's an expression body. Just wondering.
a
This would be inconsistent in that when clauses are all mutually exclusive
☝️ 1
a
Thanks! Yeah I knew it was a silly question :p
😄 1
c
Well, you can write :
Copy code
when (something) {
   FIRST_CASE -> doThis()
   SECOND_CASE -> doThat()
   else -> doSomethingElse()
 }.also { andAlwaysDoThis() }
Which is almost the same length and probably as readable, and it can still be used in single-line functions
4
a
Oh nice, thanks @CLOVIS!