What is Scala REPL?

 331 total views,  2 views today

Welcome to Scala series. In this tutorial, you will learn about What is Scala REPL and its uses.

Scala has provided an interactive command line shell to execute the programs. This is one of the major advantages of Scala.

Let us run a sample Scala command to get started.

Scala REPL

So What is Scala REPL?

REPL stands for Read, Evaluate, print and loop.

Read – reads the code

Evaluate – evaluate which compile and produces byte code

Print – print the output

Loop – loop which means it is waiting for next set of instructions

REPL can be used to write our programs in command line

If you notice, the value of i ,j and text are being stored and used in consecutive instructions. This is called an interactive feature. Scala REPL provides us an Interactive command line shell.

One thing to note is that every instruction will be treated as a separate program. Which mean, once you have declared a variable and initialized it, we can still re-declare and re-initialize the variable. Let us see with an example.

The value of i was 1 and the type was int. But We can still re-declare and re-initialize the variable. So every line of instruction will be treated as a separate program.


Scala REPL official documentation

Hope you like my post. Please leave your comments and give us a thumbs up.

Tags :

About the Author


Hey There, My name is Rajasekar and I am the author of this site. I hope you are liking my tutorials and references. Programming and learning new technologies are my passion. The ultimate idea of this site is to share my knowledge(I am still a learner :)) and help you out!. Please spread your words about us (staticreference.com) and give a thumbs up :) Feel free to contact me for any queries!.