随笔分类 -  Scala

Scala。
Scala:Functions and Closures
摘要:1 object Functions { 2 def main(args: Array[String]) { 3 // 本地函数 4 def localFun(msg: String) = println(msg) 5 localFun("Hi") 6 7 /... 阅读全文

posted @ 2015-01-11 19:53 幸福框架 阅读(448) 评论(3) 推荐(0) 编辑

Scala:Functional Objects
摘要:先上代码 1 class FunctionalObjects(var _x: Int, var _y: Int) { 2 require(_x > 0) 3 require(_y > 0) 4 5 def this(value: Int) = this(value, value) 6 ... 阅读全文

posted @ 2015-01-07 22:31 幸福框架 阅读(336) 评论(0) 推荐(0) 编辑

Scala:Method 小技巧,忽略result type之后的等号
摘要:1 var x = 0 2 3 def IncreaseOne(): Int = { 4 x += 1 5 x 6 } 7 8 def IncreaseOne() = { 9 x += 110 x11 }12 13 def IncreaseOne = {14 x += 11... 阅读全文

posted @ 2015-01-04 21:49 幸福框架 阅读(711) 评论(0) 推荐(0) 编辑

Scala:Next Steps in Scala
摘要:Array 1 val greetStrings = new Array[String](3) 2 greetStrings(0) = "Hello" 3 greetStrings(1) = "," 4 greetStrings(2) = "world!\n" 5 6 for(i "One", ... 阅读全文

posted @ 2015-01-03 20:43 幸福框架 阅读(398) 评论(0) 推荐(0) 编辑

Scala:First Steps in Scala
摘要:var and val简单来说,val声明的变量可以重新修改其引用,val则不行,见下面的例子: 1 def max(x: Int, y: Int): Int = { 2 if(x > y) x else y 3 } 4 5 def max(x: Int, y: Int): Int = i... 阅读全文

posted @ 2015-01-02 11:12 幸福框架 阅读(330) 评论(0) 推荐(0) 编辑

Scala:HelloWorld
摘要:代码1 object HelloWorld {2 def main(args: Array[String]): Unit = {3 println("Hello world") 4 }5 }解说object关键字相当于static(更确切的说法是单例模式的一种语言层面... 阅读全文

posted @ 2015-01-01 20:21 幸福框架 阅读(8428) 评论(0) 推荐(0) 编辑

Scala:使用Sublime开发Scala
摘要:学习一门新的语言时最好不要使用IDE,不过也不能走极端采用纯文本编辑器,这里采用Sublime,语法高亮显示已经默认支持了,编译系统需要自己DIY一下。这里简单的介绍一下:第一步:【Tools】【Build System】【New Build System】第二步:在打开的新文件中输入:{ "... 阅读全文

posted @ 2014-06-07 20:14 幸福框架 阅读(3574) 评论(1) 推荐(0) 编辑

Scala:Object-Oriented Meets Functional
摘要:Have the best of both worlds. Construct elegant class hierarchies for maximum code reuse and extensibility, implement their behavior using higher-orde... 阅读全文

posted @ 2014-06-06 15:26 幸福框架 阅读(267) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
我要啦免费统计
点击右上角即可分享
微信分享提示