Are there constructor references in Kotlin?

21k views Asked by At

In Java we have the Class::new syntax for constructor references. I know, there are callable references for methods, but how about constructors? A typical use case for me would be factories.

1

There are 1 answers

4
Ilya Ryzhenkov On BEST ANSWER

You can get a function instance for a constructor by simply using ::ClassName, as if it were a factory function.