Scala中复合类型实战详解之Scala学习笔记-44

package com.leegh.parameterization

import com.leegh.parameterization.Compound_Type

/**
* @author Guohui Li
*/

trait Compound_Type1;
trait Compound_Type2;
class Compound_Type extends Compound_Type1 with Compound_Type2
object Compound_Type {
def compound_Type(x: Compound_Type1 with Compound_Type2) = { println("Compound Type in global method") }
def main(args: Array[String]): Unit = {

compound_Type(new Compound_Type1 with Compound_Type2)
object compound_Type_object extends Compound_Type1 with Compound_Type2
compound_Type(compound_Type_object)

type compound_Type_Alias = Compound_Type1 with Compound_Type2
def compound_Type_Local(x: compound_Type_Alias) = println("Compound Type in local method")
val compound_Type_Class = new Compound_Type
compound_Type_Local(compound_Type_Class)

type Scala = Compound_Type1 with Compound_Type2 { def init(): Unit }
}
}

附:

本博客说明:

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

时间: 2024-10-11 12:56:26

Scala中复合类型实战详解之Scala学习笔记-44的相关文章

Scala 深入浅出实战经典 第54讲:Scala中复合类型实战详解

王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 腾讯微云:http://url.cn/TnGbdC 360云盘:http://yunpan.cn/cQ4c2UALDjSKy 访问密码 45e2土豆:http://www.tudou.com/programs/view/a6qIB7SqOlc/优酷:http://v.youku.com/v_show/id_

Scala中结构类型实战详解之Scala学习笔记-43

package com.leegh.parameterization /** * @author Guohui Li */ class Structural { def open() = print("A class instance Opened") } object Structural_Type { def main(args: Array[String]): Unit = { init(new { def open() = println("Opened")

Scala 深入浅出实战经典 第53讲:Scala中结构类型实战详解

王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 腾讯微云:http://url.cn/TnGbdC 360云盘:http://yunpan.cn/cQ4c2UALDjSKy 访问密码 45e2土豆:http://www.tudou.com/programs/view/pR_4sY0cJLs/优酷:http://v.youku.com/v_show/id_

Scala中Dependency Injection实战详解之Scala学习笔记-47

package com.leegh.parameterization /** * @author Guohui Li */ trait Logger { def log(msg: String) }trait Auth { auth: Logger => def act(msg: String) { log(msg) }} object DI extends Auth with Logger { override def log(msg: String) = println(msg)} obje

Scala中Abstract Types实战详解之Scala学习笔记-48

package com.leegh.parameterization import scala.io.BufferedSourceimport scala.io.Source /** * @author Guohui Li */trait Reader { type In <: java.io.Serializable type Contents def read(in: In): Contents}class FileReader extends Reader { type In = Stri

Scala中Self Types实战详解之Scala学习笔记-46

package com.leegh.parameterization /** * @author Guohui Li */class Self { self => val tmp = "Scala" def foo = self.tmp + this.tmp}trait S1class S2 { this: S1 => }class S3 extends S2 with S1 trait T { this: S1 => }object S4 extends T wit

Scala中SAM转换实战详解之Scala学习笔记-15

package com.leegh.function import javax.swing.JFrameimport javax.swing.JButtonimport java.awt.event.ActionListenerimport java.awt.event.ActionEvent /** * @author Guohui Li */object SAM_Curring { def main(args: Array[String]): Unit = { var data = 0; v

第58讲:Scala中Abstract Types实战详解

package com.parllay.scala.type_parameterizitor import scala.io.{Source, BufferedSource} /** * Created by richard on 15-8-17. * 第58讲:Scala中Abstract Types实战详解 */ /** * scala里的类型,除了在定义class,trait,object时会产生类型, * 还可以通过type关键字来声明类型. type相当于声明一个类型别名: scala

Scala 深入浅出实战经典 第55讲:Scala中Infix Type实战详解

王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载: 百度云盘:http://pan.baidu.com/s/1c0noOt6 腾讯微云:http://url.cn/TnGbdC 360云盘:http://yunpan.cn/cQ4c2UALDjSKy 访问密码 45e2土豆:http://www.tudou.com/programs/view/9JKSqMiQuBE/优酷:http://v.youku.com/v_show/id