mercredi 20 février 2019

Access variable name in lambda function

I'm trying to access the name of a variable inside an iterator

listOf(someClassVariable, anotherClassVariable, yetAnotherClassVariable).forEach {
    if (it.foo()) {
        map.add(it, ::it.name)
    }
}

but getting unsupported [references to variables aren't supported yet] error at ::it.name. Any ideas/workarounds?





Aucun commentaire:

Enregistrer un commentaire