I have next enum declaration:
enum class Foo(val f: (String) -> String)
And next body:
BAR({obj -> obj.toString()}),
FOO({obj -> obj.toString()})
...
Can i somehow define function for reference? Something like this:
private val predicate: (String) -> String = {obj -> obj.toString()}
And next usage:
FOO(::predicate)
This code don't compile at all (Unresolved reference: predicate
).
Update:
I'am just created companion object:
companion object Predicate {
private fun predicate(): (String) -> String {
return {obj -> obj.toString()}
}
}
And then my IDE suggested me to use another type KFunction0<(String) -> String>
. But i can i use function as param here?