title: Calling a function with with args using its reference in Scala
body: <p>Consider the following code:</p>
  
  <pre><code>object HelloIntelliScala {
    def main(args : Array[String]) = {
      println(callAnyFunc(funcWithNoArgs))
  
      val l = callAnyFuncWithArgs("bingo") (funcWithArgs)
      println(l)
  
      val l2 = callAnyFuncWithArgs(21) (funcWithArgs2)
      println(l2)
  
    }
  
    type noArgCallBack = () =&gt; Any
  
    def funcWithArgs(inp : String) : Any = {
      println("Func with arg called, arg value is: " + inp)
      "Hello " + inp + "!"
    }
  
    def funcWithArgs2(inp : Int) : Any = {
      println("Func with arg called, arg value is: " + inp)
      "Hello, integer " + inp + "!"
    }
  
    //how do i call this function?
    def funcWithArgs3(inp : Int, name : String) : Any = {
      println("Func with 2 args called, arg values are: " + (inp, name))
      "Hello, multiple args " + (inp, name) + "!"
    }
  
    def funcWithNoArgs() : Any = {
      println("Function with no args was called!")
      "Hello NO_ARGS"
    }
  
    def callAnyFunc(callback : noArgCallBack) : Any = {
      callback();
    }
  
    def callAnyFuncWithArgs[A, B](arg : A)(f : A =&gt; B) : Any = {
      f(arg);  //how do I pass variable args here
    }
  }
  </code></pre>
  
  <p>I need a generic way to call any function with arguments, just like the one without arguments. Please note that the argument list to be passed in can be variable and we do not know the arguments type's at compile time. Also I do need the Any return type since I'll need to use this value for post processing. Is there a way to do this?</p>