Can I pass an arbitrary function to another function in Scala?
问题 I'm new to Scala, and being able to pass functions to other functions is pretty neat-- but can I pass an arbitrary function reference to another function? The arity of said functional parameter will be fixed (that said, I'm also curious about whether you can pass a function with arbitrary arity as well). I keep getting tripped up on type errors. I've tried using Any but it doesn't seem to help. E.g., I have the code below: class CodeRunner(val user_defined: (Int) => Unit) { def run(input: Int