- 博客(4)
- 资源 (2)
- 收藏
- 关注
原创 scala的无参函数什么时候加括号,什么时候不加括号
在scala语言中,没有参数的函数可以加括号也可以不加括号。有什么区别呢?有括号的函数调用时可以加括号也可以不加括号 不带括号的函数调用时一定不能加括号那么具体什么情况下写无参的函数加括号,什么时候不加括号呢?无副作用的函数省略括号有副作用的函数添加括号(提醒使用者需要额外小心)
2017-12-20 11:57:04 3901 3
原创 case关键字在scala的作用
说到scala的强大,case关键字当然功不可没。它可以用作模式匹配 eg:import scala.language.postfixOpsobject fun2{ def main(args: Array[String]): Unit = { val model: Seq[(String, Int)] = ("Jack"->19)::("Bucy"->20)::("Bob"->22)
2017-12-20 11:44:10 6225 2
原创 scala的可堆叠特征
scala中trait可以提高代码的可重用性,假如有很多特质,并且特质中有着重复的方法,那么这是调用的是哪一个特质的方法?请看如下示例 trait T1{ println("T1 is created!") def myprint={ println("T1's my print") } } trait T2{ d
2017-12-12 15:24:42 320
原创 scala中extends和with的使用
在scala中有的时候用extends有的时候用with,到底该用什么呢? 请看下面用例 trait Mytrait1{ def doSomething(str:String):Unit={ println(s"$str is doing") } } trait Mytrait2{ def forfun():Unit
2017-12-11 14:48:05 15947 3
winutils.zip
2019-06-12
hadoop,spark,hbase,zookeeper,kafka配置文件
2017-10-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人