scala中List的泛型分析以及::类和Nil对象
学习了scala中List的泛型分析以及::类和Nil对象,List是对scala的类型系统的一个非常好的使用,进一步巩固List的知识对于理解scala的类型系统是非常有价值的。本讲主要分析了List的泛型、::类和Nil对象。 List有两个非常重要的子类,一个是::,一个是Nil,这两个子类都是case class。Nil表示一个空的列表,而::表达的是一个非空的列表。
例子如下:
case object Nil extends List[Nothing]{
override def isEmpty = true
override def head : Nothing = throw new NoSuchElementException("tail of empty list")
override def tail : List[Nothing] = throw new UnsupportedOperationException("tail of empty list")
override def equals(that Any) = that match{
case that1 : scala.collection.GenSeq[_] => that1.isEmpty
case _ => false
}
}
 王家林亲授《DT大数据梦工厂》大数据实战视频“Scala深入浅出实战经典”视频、音频和PPT下载!第80讲:Scala的List的泛型分析以及::类和Nil对象
腾讯微云:![]() http://url.cn/bzzNPZ
http://url.cn/bzzNPZ
百度云盘:![]() http://pan.baidu.com/s/1gdnjT3l
http://pan.baidu.com/s/1gdnjT3l
360云盘:![]() http://yunpan.cn/cd3whmTfPFGY5  访问密码 b6af
http://yunpan.cn/cd3whmTfPFGY5  访问密码 b6af
腾讯微云:
百度云盘:
360云盘:

 
                    
                 
                
            
         
 浙公网安备 33010602011771号
浙公网安备 33010602011771号