官术网_书友最值得收藏!

Using the Scala Console

The Scala console, also called Scala REPL (short for Read-Eval-Print-Loop), allows you to execute bits of code without having to compile them beforehand. It is a very convenient tool to experiment with the language or when you want to explore the capabilities of a library.

In the console, type 1+1 after the scala> prompt and hit Ctrl + Enter or cmd + Enter:

scala> 1+1

The console displays the result of the evaluation, like so:

res0: Int = 2

What happened here? The REPL compiled, evaluated the expression 1+1, and automatically assigned it to a variable named res0. This variable is of type Int, and its value is 2.

主站蜘蛛池模板: 南江县| 临西县| 加查县| 贺兰县| 苏尼特左旗| 莲花县| 岑巩县| 浮梁县| 三明市| 舒城县| 茂名市| 青龙| 柘荣县| 永和县| 武平县| 阳原县| 沾益县| 青海省| 甘德县| 九台市| 宝兴县| 泌阳县| 汾阳市| 衡南县| 阿拉尔市| 盱眙县| 滨州市| 潼南县| 弥渡县| 大石桥市| 大名县| 建阳市| 安溪县| 红桥区| 屏南县| 堆龙德庆县| 海宁市| 中阳县| 沈丘县| 阳曲县| 横峰县|