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

package com.leegh.parameterization

import scala.io.BufferedSource
import 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 = String
type Contents = BufferedSource
override def read(name: In) = Source.fromFile(name)
}

object Abstract_Types {
def main(args: Array[String]): Unit = {
val fileReader = new FileReader
val content = fileReader.read("E:\\leegh.txt")
for (line <- content.getLines())
println(line)
}
}

附:

本博客说明:

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-02 15:18:01

Scala中Abstract Types实战详解之Scala学习笔记-48的相关文章

第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 深入浅出实战经典 第58讲:Scala中Abstract Types实战详解

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

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

Spark经典视频之Scala中Self Types实战详解

王家林亲授<DT大数据梦工厂>大数据实战视频"Scala深入浅出实战经典"视频.音频和PPT下载! 欢迎广大Spark爱好者学习交流.也欢迎广大学习爱好者加入DT大数据梦工厂交流群:462923555DT大数据微信公众账号:DT_Spark 视频观看链接http://www.tudou.com/plcover/Yy5F5gsurSE/ 视频下载地址百度云:http://pan.baidu.com/s/1eQGqzEa腾讯微云:http://url.cn/SshT6b

第56讲:Scala中Self Types实战详解

今天学习了self type的内容,让我们来看下代码 package scala.learn 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 with S1object t

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_Type2object Compound_Type { def compound_

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中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中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