Is it possible to combine multiple `is` cases in a...
# getting-started
v
Is it possible to combine multiple
is
cases in a
when
block over a sealed class? I was hoping for
when(sqsMessageBody) { is SqsMsgBody.Page, SqsMsgBody.Post -> { ... } }
but IntelliJ complains that they are incompatible types. I understand why, but in my case the differences between Page and Post are irrelevant here. I'm actually just trying to avoid a catch-all
else ->
clause...
e
do you mean
is SqsMsgBody.Page, is SqsMsgBody.Post ->
(with the extra
is
)?
👍 1
as it is, you're comparing
sqsMessageBody
with the
SqsMsgBody.Post
companion object, assuming it's not an object to begin with
v
Yes, that's what I was looking for, thank you.