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.
Ilya Ryzhenkov
You can get a functional instance for constructor by simply using ::ClassName
, as if it were factory function.
来源:https://stackoverflow.com/questions/26472839/are-there-constructor-references-in-kotlin