2015年2月12日

scala学习笔记:无参函数

摘要: scala> def repeat(times:Int)(run:()=>Unit)=for(i Unit)Unitscala> repeat(2){println("haha~~~")}:9: error: type mismatch; found : Unit require... 阅读全文

posted @ 2015-02-12 17:50 白乔 阅读(405) 评论(0) 推荐(0) 编辑

scala学习笔记:函数与方法

摘要: http://stackoverflow.com/questions/2529184/difference-between-method-and-function-in-scalaAFunction Typeis (roughly) a type of the form(T1, ..., Tn) =... 阅读全文

posted @ 2015-02-12 17:31 白乔 阅读(199) 评论(0) 推荐(0) 编辑

scala学习笔记:理解函数

摘要: 定义一个函数:scala> def foo(x:Int)=x*2foo: (x: Int)Int可以采用匿名参数:scala> def foo:((Int)=>Int) = _*2foo: Int => Int这个函数的类型是Int=>Int:scala> var bar = foo... 阅读全文

posted @ 2015-02-12 11:20 白乔 阅读(129) 评论(0) 推荐(0) 编辑

导航