Scala 入门

1. 基本语法

1. 变量 var

1
2
3
var name:string="hello";
var name="hello";
var num=3.0;

2. 常量 val

1
val name="string";

3. 这里是没有 ++ 操作和 – 操作的

4. 函数调用

不用使用对象来调用,导入包以后直接调用即可

1
2
3
4
import scala.math._
sqrt(2);
pow(1,2);
min(1,2);

5.apply()

默认调用了object的apply函数

1
"hello"<6>;

6.if-else

Powered by Hexo and Hexo-theme-hiker

Copyright © 2015 - 2021 昨夜凛雨 All Rights Reserved.

UV : | PV :