Hi scala gurus
Can anyone re-write this code to do the same thing but without any compiler warnings please:-
object TestTypeErasure {
def main(args:Array[String]) {
def myFunction(myObject:Any):Boolean = {
true
}
val myVariable: (Any => Boolean) = myFunction
myVariable match {
case function:(Any => Boolean) => println("Match")
}
}
}
Thousand thankyous
Keith
Update!!!!. Sorry making a real hash of this. Its my first question on SO
Just to let the gurus know I have tried something along the lines of this also to no avail:- (Can't compile it)
object TestTypeErasure {
def doTest(parameter: Any) = {
parameter match {
case function:Function1[_, _] => function("Whatever")
}
}
def main(args:Array[String]) {
}
}
I get error :-
TestTypeErasure.scala:6: error: type mismatch;
found : java.lang.String("Whatever")
required: _
case function:Function1[_, _] => function("Whatever")
^
one error found
Thanks again
Keith