Generic inline classes in Kotlin 1.7.20

Поделиться
HTML-код
  • Опубликовано: 2 ноя 2024

Комментарии • 15

  • @kaopesa
    @kaopesa Год назад

    Hey, I Sebastian, I just wanted to say that you look great.

  • @ChrisAthanas
    @ChrisAthanas 2 года назад +1

    Im using IntelliJ IDEA 2022.2.3 (Community Edition), and have updated my `plugins Kotlin("jvm") version "1.7.20"`, and added the `kotlinOptions.languageVersion="1.8"`, and the compiler is complaining about the generic parameter on the `HighQuality` value class.
    Is it possible to post this project to a github to see what Im missing here?

    • @ChrisAthanas
      @ChrisAthanas 2 года назад +1

      Looks like i had to also update the Kotlin version in the "tools-->Kotlin->Configure kotlin plugin updates" and download the 1.7.20 stable version and restart the IDE.

  • @AndrasHatvani
    @AndrasHatvani 2 года назад

    ‪In the video a custom data class will be wrapped in an inline class, but in the documentation explicitly primitive values will be mentioned - why are both allowed and what sense does wrapping the custom class with potentially multiple properties make?‬

    • @abunapha
      @abunapha 2 года назад +1

      Primitive wrapped by normal class: 1 stack allocation + 1 object allocation
      Primitive wrapped by inline class : 1 stack allocation
      class with no fields wrapped by normal class: 2 object allocations
      class with no fields wrapped by inline class: 1 object allocation
      Class with 1 primitive field wrapped by normal class: 1 stack allocation + 2 object allocations
      Class with 1 primitive field wrapped by inline class: 1 stack allocation + 1 object allocation
      Class with 5 primitive fields wrapped by normal class: 5 stack allocations + 2 object allocations
      Class with 5 primitive fields wrapped by inline class: 5 stack allocations + 1 object allocation
      Inline classes remove the overhead of creating an object in all cases.

  • @AhmadSattout97
    @AhmadSattout97 2 года назад +2

    Why does IDEA look so much different on Mac

    • @luizrcs
      @luizrcs 2 года назад +3

      i'd love to know what theme he's using for the sidebars

    • @Oeoaea
      @Oeoaea 2 года назад +10

      it's not mac specific, it's the new ui available as a preview

    • @replicant9611
      @replicant9611 2 года назад

      @@Oeoaea I thought it's their new Fleet text editor

  • @brandonkagunde4193
    @brandonkagunde4193 2 года назад

    wow dude i love u, it really works!

  • @yangqiou3753
    @yangqiou3753 2 года назад

    another extra key word value? Happy refactoring...

  • @Denis-ez8gd
    @Denis-ez8gd 2 года назад +1

    So, if I start using generic inline classes from java, I could still get runtime error, because we will have `Object foo` in some cases, right?

  • @jt_hopp
    @jt_hopp 2 года назад +6

    Dönerliebe

  • @mohsenrzna8473
    @mohsenrzna8473 Год назад

    Amazing toturials! Thanks!
    Anyways, you look different :)