hikamaeng
03/27/2024, 1:37 AMclass Some private constructor(val v:Any){
companion object:(Any)->Some{
override fun invoke(v:Any) = Some(v)
}
}
fun <T, R> needFactory(v:T, factory:(T)->R):R = factory(v)
needFactory(3, Some)
Implementing lambda is one of the simplest ways to create a factory ^^Arjan van Wieringen
03/27/2024, 6:12 AMArtem Kobzar
03/27/2024, 8:16 AMEdoardo Luppi
03/27/2024, 8:36 AMneedFactory
I think the key point is the behavior of the language is different depending on the target, which is unexpected.
To me it looks a good enhancement, the only thing, as Artem wrote, is I wouldn't like more overhead than what's necessary. That is, if a fix for this messes up something else, then better avoid.hikamaeng
03/29/2024, 12:18 PM