<Extension Constructors> Kotlin supports a great d...
# forum
r
Extension Constructors Kotlin supports a great deal of extension functions, allowing us to customize classes from other libraries a lot. The only feature we cannot extend is constructors. Constructors are commonly imitated in libraries like JetBrains Compose: class MyFunnyClass(val string: String) fun MyFunnyClass(int: Int?) : MyFunnyClass = MyFunnyClass(int.toString()) However, there are a few problems with this syntax: IDE highlighting - the IDE considers this a function, not a constructor. As such, custom...