标签:
学习了scala模式匹配下的提取器动手构造实战,提取器的名称:>,提取器方法unapply,返回最后一个元素,和最后一个元素以前的若干元素,匹配最后一个元素是9,前面的是8,例子下:
Object :>{
Def unapply[A](List:List[A])={
Some((list.init,list.last))
}
}
Object Extractor_Advanced{
Def main(args:Array[String]){
(1 to 9).toList match{ case_ :> 9 =>println(“Hadoop”)}
(1 to 9).toList match{ case_ :> 8:>9 =>println(“Spark”)}
(1 to 9).toList match{ case :>(:> (_,8):>9) =>println(“Spark”)}
http://pan.baidu.com/s/1dD10KFZ
http://url.cn/d8FtbN
http://yunpan.cn/cdZCgEx2kzytv 访问密码 3c53
标签:
原文地址:http://www.cnblogs.com/tom-lee/p/4700893.html