Thread
#reflect
    d

    Daniele B

    2 years ago
    var myVar : String
        get() = functionUsingTheVariableName(::field.name)
    I would like to do this, but I get:
    Unsupported [References to variables aren't supported yet]
    any alternative?
    e

    ephemient

    2 years ago
    why not
    functionUsingTheVariableName(::myVar.name)
    ?
    else you could probably get super fancy with
    operator fun <T> ((String) -> T).getValue(thisRef: Any?, property: KProperty<*>): T = invoke(property.name)
    
    val myVar: String by ::functionUsingTheVariableName
    d

    Daniele B

    2 years ago
    the whole point is was not to repeat the name of the variable
    but yes, I looked into the Delegated Properties and I also found it suits the best!
    thanks