Sam
07/29/2022, 7:58 AM(A) -> B
, it’d be cool to be able to just pass ::foo
instead of A::foo
. Is there a name for what I want? Even better, is there an existing ticket/proposal for it?
Example:
data class A(val name: String)
fun <B> A.getProp(prop: (A) -> B) = prop(this)
fun A.getName() = getProp(::name) // I want this
fun A.getName2() = getProp(A::name) // But I have to do this instead
assertk
, where I end up with things like:
assertThat(actual)
.isInstanceOf(ExpectedClass::class).all {
prop(ExpectedClass::a).isEqualTo(expectedA)
prop(ExpectedClass::b).isEqualTo(expectedB)
}
ExpectedClass
over and over againprop { it. a }
), so that when the assertion fails it will include the name of the propertyChrimaeon
07/29/2022, 8:18 AMSam
08/04/2022, 7:48 AM