How do you start scala study
where to coding?
- databricks
- sign up a databricks community account
- run on a cluster
- create a scala notebook
basic grammar
- do not use ‘;’
- 初始化时,不需要数据类型或返回类型;
- val是常量;var是变量; def是函数声明;
- 命名,区分大小写; 类(驼峰式MyFirstClass)函数(驼峰式myFirstFunction)
- 文件名与类 同名;
- Scala访问数组的语法是使用()而非[;
- Scala中的main函数:
def main(args:Array[string])
run a scala code
- create Helloworld.scala file
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world! This is my first Scala Program");
}
}
- 终端
scalac HelloWorld.scala
scala HelloWorld