How did anonymous function implements the trait?
问题 let's see the code in scala REPL: first, i defined a trait: trait Service{ def invoke(name:String):String } then i defined an anonymous function: def serviceImpl:Service = (name)=> s"Your name is $name" It works fine. the serviceImpl method returns an anonymous function --- " (name)=> s"Your name is $name" " is just an instance of Function2[String, String] trait. but as above, how the anonymous function implements the Service trait? and How scala does this convert? 回答1: This is a new feature