问题标签 [constructor-reference]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
800 浏览

java - What is the purpose of constructor references in Kotlin

I am reading the book Kotlin in action and I ask myself what is the purpose of "creating an instance of a class using a constructor reference" (page 112 if anyone is interested and has the book at home).

Here is the code example from the book:

I think it looks like an factory method call, but I dont think that this is the (only) purpose of the method reference here.

0 投票
1 回答
39 浏览

kotlin - 如何在 Kotlin 中引用参数化构造函数?

所以我有这个定义:

我想将某些元素包装在 Success 中。我知道我可以这样做......

但是有没有办法使用构造函数引用?