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

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.

主站蜘蛛池模板: 招远市| 昆山市| 曲靖市| 松原市| 钟山县| 封开县| 云南省| 湘潭市| 常熟市| 蕲春县| 托里县| 乐山市| 齐齐哈尔市| 镇原县| 绥阳县| 姜堰市| 江永县| 大港区| 厦门市| 平和县| 丰顺县| 河池市| 民勤县| 托克托县| 德格县| 乐业县| 健康| 汝城县| 溆浦县| 团风县| 恩施市| 潢川县| 卓资县| 阜阳市| 洛南县| 龙里县| 札达县| 拜城县| 疏附县| 绥宁县| 方山县|