DT大数据梦工厂 第55,56讲

王家林亲授《DT大数据梦工厂》大数据实战视频“Scala深入浅出实战经典”视频、音频和PPT下载!第55讲:Scala中Infix Type实战详解
百度云盘:http://pan.baidu.com/s/1c06RqX6
腾讯微云:http://url.cn/fPp32J
360云盘:http://yunpan.cn/ccri9EJhwn4nQ 访问密码 80af
本节王老师讲了中值类型。首先介绍一下方法放在2个参数中间的情况:
object Log { def >>:(data:String):Log.type={println(data);Log}}
由于这个方法是向右结合,所有可以写成“Hadoop”>>:"Spark">>:Log 这样就说明Log.>>:("Spark").>>:("Hadoop")
然后就是真正的中值类型
class Index_Type[A,B]
val infix: Int Index_Type String =null;
这个infix 就是Int Index_Type String类型的,表名他的左边是整数,右边是String。
还有
case class Cons(first:String,second:String)
val case_class=Cons("one","two")
case_class match{case "one" Cons "two" => println("hehe")}
如果case_class是"one" Cons "two" 类型的,就呵呵
王家林亲授《DT大数据梦工厂》大数据实战视频“Scala深入浅出实战经典”视频、音频和PPT下载!第56讲:Scala中Self Types实战详解
百度云盘:http://pan.baidu.com/s/1i3H6zDb
腾讯微云:http://url.cn/WCjiGK
360云盘:http://yunpan.cn/ccxeFvCySXu7i 访问密码 0c64
这一讲王老师讲了this的别名,Self Type。
class Self{
self =>//表示this的别名
val temp="Spark"
def foo=self.temp+this.temp
}
这里的self就是this的别名,他的作用和this一样。这个名可以随便起,但是不能是this。
如果是this做为this的别名,那么,就需要有限定条件。
trait S1
class S2{
this:S1 =>//这就表示要想实例化这个类,必须混入trait S1这个特质
}
所以有
class S3 extends S2 with S1//这个with S1是必须的。
当然也有
trait T{ this:S1 =>}
object S4 extends T with S1 这也是必须的

posted on 2015-07-17 14:09  trgaaaaa  阅读(122)  评论(0编辑  收藏  举报