benleggiero
12/17/2017, 6:56 PMreturn
makes sense in a `constructor`…elect
12/18/2017, 8:45 AMbenleggiero
12/19/2017, 2:21 PMconstructor
always creates a new instance. If you look above, I suggested a “failable” constructor, which might return null
if some conditions aren’t met. It was pointed out to me that placing a operator fun invoke(
inside the class’s companion object
gives the same effect. You should try that!dmitry.petrov
12/19/2017, 3:32 PMclass C(val x: Int)
fun C(xs: List<Int>) = x.singleOrNull()?.let { C(it) }
Can't say I like any of these styles, thoughbenleggiero
12/22/2017, 6:39 PMdmitry.petrov
12/22/2017, 7:39 PM