local custom getter? (inside a function)
# language-proposals
e
local custom getter? (inside a function)
d
Example?
m
You kinda can already using delegation:
Copy code
interface Delegation<Value> {
	operator fun getValue(thisRef: Any?, property: KProperty<*>): Value
}

fun <Value> delegation(block: () -> Value) = object : Delegation<Value> {

	override fun getValue(thisRef: Any?, property: KProperty<*>) = block()
}


fun main() {
	val foo by delegation { 42 }

	println(foo) // 42
}
If that’s what you mean 😄
If you mean
val SomeClass.foo get() = 42
then that indeed won’t work.
e
Copy code
fun foo() {
   val a get() = 2
}
👍 1