Thread
#stdlib
    m

    mg6maciej

    4 years ago
    Should I use
    someMap.filterValues { it != null }.mapValues { it.value as Any }
    or is there anything like
    someList.filterNotNull()
    for Maps?
    ilya.gorbunov

    ilya.gorbunov

    4 years ago
    karelpeeters

    karelpeeters

    4 years ago
    Is there no general solution coming for this? Ie. also for
    .filter { it is String }
    .
    m

    mg6maciej

    4 years ago
    @karelpeeters
    listOf<Any>().filterIsInstance<String>()
    exists.
    karelpeeters

    karelpeeters

    4 years ago
    Hmm, okay. Still, I wonder if it is possible to get the typesystem to understand things like this?
    ilya.gorbunov

    ilya.gorbunov

    4 years ago
    @karelpeeters It was a use case for contracts to express the relation between
    filter
    predicate and the return type, however we haven't yet found the way to express that (@dsavvinov correct me if I'm wrong)
    karelpeeters

    karelpeeters

    4 years ago
    That's unfortunate. I'm looking forward to the contract stuff though!
    marcinmoskala

    marcinmoskala

    4 years ago
    You can make it yourself 😉