標籤:
package com.leegh.parameterization
/**
* @author Guohui Li
*/
//由於breathe返回的是this,scala將傳回型別推斷為Animal,而由於Animal沒有eat方法
//class Animal { def breathe = this }
//class Cat extends Animal { def eat = this }
class Animal { def breathe: this.type = this }
class Cat extends Animal { def eat: this.type = this }
object Singleton_Types {
def main(args: Array[String]): Unit = {
val cat = new Cat
cat.breathe.eat
}
}
附:
本部落格說明:
1.整理思路,提高自己。
2.受教於王家林老師,?有所收穫,故推薦。
3.部落格注重實踐,多餘的文字就不多說了,都是做技術的。
4.資訊來源於 DT大資料夢工廠公眾帳號:DT_Spark。?
DT大資料夢工廠的公眾號是DT_Spark,每天都會有大資料實戰視頻發布,請您持續學習。
王家林DT大資料夢工廠scala的所有視頻、PPT和代碼在百度雲端硬碟的連結:http://pan.baidu.com/share/home?uk=4013289088#category/type=0&qq-pf-to=pcqq.group
王家林《Scala深入淺出實戰初級入門經典視頻課程》http://edu.51cto.com/lesson/id-66538.html
王家林《Scala深入淺出實戰中級進階經典視頻課程》http://edu.51cto.com/lesson/id-67139.html
Scala中鏈式調用風格的實現代碼實戰及其在Spark編程中的廣泛運用之Scala學習筆記-41