https://kotlinlang.org logo
Title
c

christophsturm

10/25/2018, 7:19 PM
for generic classes it would be really nice to have a inline reified constructor, or a inline reified factory method that is called like the class to make it look like a constructor invocation.
s

Shawn

10/25/2018, 7:21 PM
define an
inline operator fun invoke()
in your class’s companion object
gets pretty close
can make the primary constructor private if you need to
c

Casey Brooks

10/25/2018, 7:21 PM
That was my first thought as well
c

christophsturm

10/25/2018, 7:21 PM
oh wow thats an interesting idea thanks for that
👍 1
k

karelpeeters

10/25/2018, 7:40 PM
Or just a normal function that has the same name as the class.
c

christophsturm

10/25/2018, 7:42 PM
thats what i did before, but then idea warns that a function should not start with an uppercase letter
k

karelpeeters

10/25/2018, 7:42 PM
Supress that 😒imple_smile:.
🎉 1
:trollface: 3
😮 2