181 total views, 3 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.
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.
Hope you like my post. Please leave your comments and give us a thumbs up.