https://kotlinlang.org logo
#feed
Title
t

Tower Guidev2

08/04/2021, 2:29 PM
Hi, Im new to Kotlin and enjoying it so far 😉
👍 1
K 8
Im investigating the use of
when
I have a sealed class of values and want to identify each case as shown below
*when*(x) {
*is* SealedInitial -> doNothing()
*is* SealedOne -> something(x.value)
*is* SealedTwo -> somethingElse(x.value)
*else* -> doNothing()
}
I have to perform this test "All Over" my application, however the only constant check I will always need is the first one, e.g.
*is* SealedInitial -> doNothing()
I would like to have thi scase handled by a super class so that all my Sub Classes do not need to keep coding that line Is this possible? To have a
when
statement "extend" a super
when
?
r

Ruckus

08/04/2021, 2:36 PM
Good to hear you're enjoying yourself 🙂 Just so you're aware, this is the wrong channel for this kind of post. The channel topic says:
Post links to interesting things about Kotlin. Discuss in the relevant channel, not here.
This channel is meant to be more of a news feed than a discussion area.
t

Tower Guidev2

08/04/2021, 2:37 PM
oh, my mistake 🤦‍♂️ sorry
I do not see a Discuss channel though
r

Ruckus

08/04/2021, 2:38 PM
No problem. I'd recommend #getting-started, though #general would also work fine.
👍 1
"Discuss in the relevant channel" means to discuss in the channel that fits the topic (not in a channel named discussion).
t

Tower Guidev2

08/04/2021, 3:13 PM
gotcha , 😄 My mistake again 😄
3 Views