How to implement Builder pattern in Kotlin?

后端 未结 13 1645
半阙折子戏
半阙折子戏 2020-11-29 16:18

Hi I am a newbie in the Kotlin world. I like what I see so far and started to think to convert some of our libraries we use in our application from Java to Kotlin.

T

13条回答
  •  孤街浪徒
    2020-11-29 16:55

    I would say the pattern and implementation stays pretty much the same in Kotlin. You can sometimes skip it thanks to default values, but for more complicated object creation, builders are still a useful tool that can't be omitted.

提交回复
热议问题