case class Meth(name: String, typ: Type, np : Int )
def lookupMethod(cls:String,mth:String,np:Int,list:List[MyClassType]):Option[Meth] =
{ .....
val findMeth = listMeth.find( a = > ( a.name == mth && a.np == np) )
.....
}
我有listMeth:List [Meth],我想找到具有“ mth ”名称和“ np “参数。我上面的代码不起作用,所以如何修复它?
答案 0 :(得分:3)
=>
没有空格:
def lookupMethod(cls: String, mth: String, np: Int, list: List[MyClassType]): Option[Meth] = {
listMeth.find(a => a.name == mth && a.np == np)
}