Scala基础
文章平均质量分 55
Gerald Kwok
低到尘埃里,才能开出花来。
展开
-
Scala---五种常见的模式匹配
Scala 五种常见的模式匹配1. 常量模式常量模式包含常量变量和常量字面量object PatternMatch { // 字面常量 val BYTEDANCE = "bytedance.com" def foo(s: String): Unit = { s match { case BYTEDANCE => println("ok") case _ => println("can not match") } } def m原创 2021-04-16 19:45:31 · 2468 阅读 · 0 评论 -
globStatus 使用小结
globStatus(Path pathPattern)Return all the files that match filePattern and are not checksum files.大体上说就是返回所有匹配到的文件路径。个人使用心得:该 API 支持使用 Shell 通配符来匹配文件,若需要对文件进行筛选,可以在查出来文件路径后进行 filter。fileFs.globStatus(new Path(regexHdfsPath)).map(_.getPath.toString).原创 2020-12-20 15:25:31 · 501 阅读 · 1 评论 -
Scala 的 Symbol 类型
This class provides a simple way to get unique objects for equal strings. Since symbols are interned, they can be compared using reference equality. Instances of Symbol can be created easily with Scala’s built-in quote mechanism.大概翻译一下:这个类提供了一个快速的字符串比较方.原创 2020-07-15 18:55:05 · 215 阅读 · 0 评论 -
Scala 方法与函数
Scala 方法与函数方法的定义object Scala_Function { def main(args: Array[String]): Unit = { def max(lhs: Int, rhs: Int): Int = { if (lhs >= rhs) { // return lhs lhs } else {...原创 2020-04-22 15:57:51 · 201 阅读 · 0 评论 -
Scala 条件语句和循环
Scala 条件语句和循环该篇博客仅适用于已经有至少一门的语言基础的同学If ElseScala 的条件判断语句跟其他语言没什么不同,就是判断的时候需要加上括号。Golang 在判断的时候就不需要加括号。 if (age < 20) { println(s"$age ") } else if (age >= 20 && age...原创 2020-04-22 13:53:12 · 169 阅读 · 0 评论