吹静静

欢迎QQ交流:592590682

Scala官网:https://docs.scala-lang.org/tour/basics.html

val(Values)

  Named results, such as x here, are called values. Referencing a value does not re-compute it.

  x = 3 // This does not compile.

var(Variables)

  Variables are like values, except you can re-assign them. You can define a variable with the var keyword.

  var x = 1 + 1

  x = 3 // This compiles because "x" is declared with the "var" keyword.

  println(x * x) // 9

posted on 2021-02-25 14:28  吹静静  阅读(137)  评论(0编辑  收藏  举报