Thread
#stdlib
    m

    madorb

    4 years ago
    so, i just asked this in general, but i see this the questions here are related… is there any commonly-used library, that’s like “kotlin: the missing bits” that extends the stdlib with various convenience functions that perhaps haven’t yet made it into the stdlib?
    elizarov

    elizarov

    4 years ago
    There are various
    kotlinx
    things but they are not just "missing bits", but big cohesive chunks. There is nothing like Guava -- stdlib is for that.
    Are you looking for anything specific that you think is missing from stdlib?
    m

    madorb

    4 years ago
    no, not anything specific necessarily, but there are a number of methods, like the the one i put in #general (
    String?.ifNullOrBlank(altValue: String): String
    ) that i think could be generally useful but that aren’t in the stdlib . The various types of things that have traditionally ended up in apache commons StringUtils, DateUtils, etc. or Guava. Obviously a lot of that functionality is in the standard lib, but not all of it
    i’m finding myself creating my own
    String.kt
    with small 1-liner extension functions that i can reuse across projects, so was curious if there is any sort of community library that has traction that does the same
    elizarov

    elizarov

    4 years ago
    Just post those snippets to this channel. Maybe there are already concise equivalents in stdlib or they will become candidates for future improvements in stdlib
    Btw, your particular use-case is quite idiomatically written as
    str?.takeUnless { it.isEmpty() } ?: altValue
    P.S. the extension like
    String?.ifNullOrBlank
    is unlikely to ever make it to stdlib, since nullable strings are very uncommon in idiomatic Kotlin code. Idiomatic Kotlin code tends to have very few nullable variables.
    m

    madorb

    4 years ago
    agreed on that - that’s why i was initially asking about a 3rd party library, some things may make no sense at all in idiomatic kotlin, but could be nice-to-haves when interacting with java