t

    Tower Guidev2

    1 year ago
    Hi, Im new to Kotlin and enjoying it so far 😉
    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

    1 year ago
    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

    1 year ago
    oh, my mistake 🤦‍♂️ sorry
    I do not see a Discuss channel though
    r

    Ruckus

    1 year ago
    No problem. I'd recommend #getting-started, though #general would also work fine.
    "Discuss in the relevant channel" means to discuss in the channel that fits the topic (not in a channel named discussion).
    t

    Tower Guidev2

    1 year ago
    gotcha , 😄 My mistake again 😄