79604085

Date: 2025-05-02 20:42:25
Score: 1.5
Natty:
Report link

To clarify the "reflection" solution of @AlexeyRomanov, Scala (version 3.6.x) expects an instance as the first argument of the invoke method, as follows:

// assumes func has exactly one apply method, modify to taste
val instance = func.getClass.newInstance
val method = instance.getClass.getMethods.filter(_.getName == "apply").head
method.invoke(instance, arr: _*)
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @AlexeyRomanov
  • Low reputation (1):
Posted by: TL K