scala apply unpdate unpply



object Name{

def unapply(str:String)={
val pos = str.indexOf(" ")
if(pos == -1)None else Some(str.substring(0,pos),str.substring(pos+1))
}

}

 

 样板类具有apply和unpply方法 

 

 

 

 

posted @ 2018-12-28 18:20  Commander·  阅读(105)  评论(0编辑  收藏  举报