I'll bite: How would you use this? What the use ca...
# random
k
I'll bite: How would you use this? What the use case?
☝️ 2
r
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
Copy code
procedure {
    when (it) {
        "a" -> 1
        "b" -> 2
        "c" -> 3
        ...
        else -> error("Invalid input")
    }
}
I can do this:
Copy code
procedure(mapOf("a" to 1, "b" to 2, "c" to 3, ...))
k
That's quite a specific use case simple smile
r
Indeed 🙂