What is recommended to do when you have a case in ...
# getting-started
k
What is recommended to do when you have a case in a when where you want do to noting? Just empty {}?
m
Or just nothing? Do you mean a lambda for a NOOP (no operation)? I'd usually use empty braces indeed, e.g.
Copy code
val operation: (InputValue)->Unit = {}
t
I suggest functionally empty braces with a comment like this:
Copy code
when (a) {
  1 -> doSomething()
  2 -> { /* do nothing */ }
  3 -> throw MyException()
}
2
👍 2
e
I like writing
Unit
, more than {}, but it works the same