I wasn't really going for a bite, more just showing some really weird yet still useful code. But to answer your question: Assume we have a function that returns a value. That function takes as a parameter another function that takes a string and returns a value. This lets me pass in a map of strings to values in place of that function parameter.
For context, it's for a function that can be executed in a context, and can get data from that context by passing it string keys. I wanted to test it by faking the context using predefined values.
tldr: Instead of this
procedure {
when (it) {
"a" -> 1
"b" -> 2
"c" -> 3
...
else -> error("Invalid input")
}
}
I can do this:
procedure(mapOf("a" to 1, "b" to 2, "c" to 3, ...))