Problem : I have to call Objects methods which stored in a map, for a given key how to do it ? Code :
trait Processor00 { def process(x:String): Unit } case class Processor20() extends Processor0 { override def process(x:String): Unit = println("Processor20 x :" + x) } case class Processor30() extends Processor0 { override def process(x:String): Unit = println("Processor30 x :" + x) } object UnitTest1 { def main( args : Array[String]):Unit ={ val s:String = "yes" val myFuncs: Map[String,(String) => Unit ]= Map( "string2" -> Processor20().process(s), //Eroor 1. type mismatch; found : Unit required: String ⇒ Unit "string3" -> Processor30().process(s) ) myFuncs.values.foreach(v => v());//how to call all Objects' i.e. process("Hi") here ??? } }