2015年9月17日

摘要: 今天学习了下隐式转换的内容。所谓隐式转换,就是说,一个实例拥用1 2 3方法,但是当它需要4方法的时候,它没有,但是却可以通过转换成另一种类型来调用4方法,而且这种转换是自动转换不需要人为干预的,这种形为就叫做隐式转换。让我们通过实例来分析一下:import java.io.Fileimport s... 阅读全文
posted @ 2015-09-17 00:17 晴月sama 阅读(192) 评论(0) 推荐(0)

2015年9月15日

摘要: 这一讲我们来学习下抽像类型。让我们看下代码package scala.learnimport scala.io.BufferedSourceimport scala.io.Sourcetrait Reader{ type In type Contents def read(in:In):Conten... 阅读全文
posted @ 2015-09-15 18:43 晴月sama 阅读(168) 评论(0) 推荐(0)
 
摘要: 本讲我们来学习下依赖注入。让我们从代码出发:package scala.learntrait Logger {def log (msg:String)}trait Auth { auth:Logger => def act (msg:String){ log(msg) }}object DI ext... 阅读全文
posted @ 2015-09-15 17:43 晴月sama 阅读(188) 评论(0) 推荐(0)
 
摘要: 今天学习了self type的内容,让我们来看下代码package scala.learnclass Self{ self => val tmp = "Scala" def foo = self.tmp + this.tmp}trait S1class S2 {this:S1 =>}class S3... 阅读全文
posted @ 2015-09-15 12:58 晴月sama 阅读(761) 评论(0) 推荐(0)

2015年9月11日

摘要: 今天学习了Infix type的知识,来看看实战代码: def main(args:Array[String]){ object log { def >>:(data:String):log.type = {println(data);log}} "Hadoop" >>: "spark" >>: l... 阅读全文
posted @ 2015-09-11 20:46 晴月sama 阅读(192) 评论(0) 推荐(0)

2015年9月10日

摘要: 今天学习了scala的复合类型的内容,让我们通过实战来看看代码:trait Compound_Type1trait Compound_Type2class Compound_Type extends Compound_Type1 with Compound_Type2object test54 { ... 阅读全文
posted @ 2015-09-10 23:28 晴月sama 阅读(272) 评论(0) 推荐(0)

2015年9月9日

摘要: 今天学习了scala的结构类型,让我们看看代码class Structural {def open() = print("A class interface opened") }object test53 { def main(args:Array[String]){ init(new {def o... 阅读全文
posted @ 2015-09-09 22:58 晴月sama 阅读(251) 评论(0) 推荐(0)

2015年9月8日

摘要: 今天学习了scala中的路径依赖,来看一下实战代码class Outer{ private val x = 10 class Inner{ private val y = x +10 }}这里定义了一个外部类Outer,Outer里定义了私有的成员x。同时定义了内部类Inner,内部类里定义了私有成... 阅读全文
posted @ 2015-09-08 21:52 晴月sama 阅读(231) 评论(0) 推荐(0)
 
摘要: 今天学习了下scala中的链式调用风格的实现,在spark编程中,我们经常会看到如下一段代码:sc.textFile("hdfs://......").flatMap(_.split(" ")).map(_,1).reduceByKey(_ + _)........这种风格的编程方法叫做链式调用,它... 阅读全文
posted @ 2015-09-08 21:25 晴月sama 阅读(660) 评论(0) 推荐(0)
 
摘要: 今天学习了scala的多重界定T >: A :A with BA或B是T的子类T <% A <% BT同时满足能够即可以通过隐式转换转变为A的类型,也可以通过隐式转换变为B的类型。T : A : BT必须同时满足存在A[T]这种类型的隐式值和B[T]类型的隐式值。分享下更多的scala资源吧:百度云... 阅读全文
posted @ 2015-09-08 20:17 晴月sama 阅读(178) 评论(0) 推荐(0)