In my limited experience with Scala, there is a error in my code:
class TagCalculation {
def test_string(arg1: String,arg2: String) = arg1 + " " + arg2
def test_int(arg1: Int,arg2: Int) = arg1 + arg2
}
val get_test = new TagCalculation
//test int, by the way it's Ok for String
val test_int_para = Array(1,2)
val argtypes2 = test_int_para.map(_.getClass)
val method2 = get_test.getClass.getMethod("test_int", argtypes2: _*)
method2.invoke(get_test,test_int_para: _*)
Outputs:
console>:29: error: type mismatch;
found : Array[Int]
required: Array[_ <: Object]
method2.invoke(get_test,test_int_para: _*)
Why did this error happened?
Array[Object]
(or declare it as that type)... – insan-e