Thread
#compose
    Siyamed

    Siyamed

    2 years ago
    Which one is more kotliner: A “Builder” object functions should (1️⃣return this ) or (2️⃣let me use with/apply etc and don’t return this)
    e

    efemoney

    2 years ago
    Correct me if i’m wrong but you mean:1️⃣
    Builder()
      .function()
      .anotherFunction()
      .build()
    2️⃣
    Builder().apply {
      function()
      anotherFunction()
    }
    right?
    louiscad

    louiscad

    2 years ago
    No builder and default argument values is more Kotliny
    m

    Matej Drobnič

    2 years ago
    Even if you return this, you can stull use with/apply etc., so I do not see why you would not return this if you are using builder. There is no downside. But otherwise I agree with @louiscad
    Siyamed

    Siyamed

    2 years ago
    Thanks. Efeturi that's correct.
    Louis, Regarding the default argument, this is more like StringBuilder, it actually is AnnotatedStringBuilder in order to assist construction of a styled string
    StringBuilder seems to be an alias to java one, so I wasn't sure what it would look like if was implemented in kotlin
    Thank you all for the responses.
    louiscad

    louiscad

    2 years ago
    Don't you already have
    buildSpannedString { … }
    + extensions for
    SpannedStringBuilder
    in AndroidX Core KTX? You would just add another one for annotations, right?
    Siyamed

    Siyamed

    2 years ago
    AnnotatedString.Builder will be a Compose component and will be the equivalent of/similar SpannableStringBuilder. Planning to add buildAnnotatedString {...}.
    louiscad

    louiscad

    2 years ago
    Oh yeah, that's why this thread is in the #compose channel. Will it be Android only, or multiplatform ready?
    AnnotatedString is a regular data class
    louiscad

    louiscad

    2 years ago
    How would that work with localization? A big when expression? Retrieve from resources on Android? Something else?
    Also, is there a reason this doesn't implement
    Appendable
    ?
    Siyamed

    Siyamed

    2 years ago
    Regarding i18n, that is a wider concept and not defined yet.
    Regarding appendable, no charsequence support for now. Charsequence bites us on android.
    Wait 😃 I understand that you think AnnotatedString is directly related to annotation class and tag on Android?
    If so, that is not something we intended to 😕
    louiscad

    louiscad

    2 years ago
    I though it was related to the annotation spans you can put in string resources or
    SpannedString
    , but it seems it's not after all.
    Charsequence bites us on android
    How?