简体   繁体   中英

Using Find function in scala

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) )
.....
}

I have listMeth : List[Meth] , and I want to find the method which have the " mth " name and the " np " parameters . My above code doesnt work,so how to fix it ?

=> is written without space:

 def lookupMethod(cls: String, mth: String, np: Int, list: List[MyClassType]): Option[Meth] = {
    listMeth.find(a => a.name == mth && a.np == np)
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM