Scala | REPL Last Updated : 28 Feb, 2023 Comments Improve Suggest changes Like Article Like Report Scala REPL is an interactive command line interpreter shell, where REPL stands for Read-Evaluate-Print-Loop. It works as it stands for only. It first Read expression provided as input on Scala command line and then it Evaluate given expression and Print expression’s outcome on the screen then it is again ready to Read and this thing goes in a loop. In the scope of the current expression, as required, previous results are automatically imported. The REPL reads expressions at the prompt In interactive mode, then wraps them into an executable template, and after that compiles and executes the result. Implementation Of REPL Either an object Or a class can be wrapped by user code the switch used is -Yrepl-class-based.Each and every line of input is compiled separately.The Dependencies on previous lines are included by automatically generated imports.The implicit import of scala.Predef can be controlled by inputting an explicit import.We can start Scala REPL by typing scala command in console/terminal. $scala Let's understand how we can add two variables using Scala REPL. In the first line, we initialized two variables in Scala REPL. Then Scala REPL printed these. In this we can see that internally it create two variable of type Int with value. Then we executed the expression of sum with defined two variables. with this Scala REPL printed the sum of the expression on the screen again. Here it did not have any variable so it showed it with its temporary variable only with prefix res. We can use these variables the same as we created them. We can get more information on these temporary variables by calling getClass function over these variables like below. We can do lots of experiments like this with scala REPL on run time which would have been time-consuming if we were using some IDE. With scala2.0 we can also list down all function suggestions that we can apply to variables by pressing the TAB key. Some More Important Features of REPL IMain of REPL is bound to $intp.The tab key is used for completion.lastException binds REPL's last exception.:load is used to load a REPL input file.:javap is used to inspect class artifacts.-Yrepl-outdir is used to inspect class artifacts with external tools.:power imports compiler components after entering compiler mode.:help is used to get a list of commands to help the user. Comment More info N NishanthVaidya Follow Improve Article Tags : Scala Scala Scala-Basics Explore OverviewScala Programming Language3 min readIntroduction to Scala7 min readSetting up the environment in Scala3 min readHello World in Scala2 min readBasicsScala Keywords2 min readScala Identifiers3 min readData Types in Scala3 min readVariables in Scala3 min readControl StatementsScala | Decision Making (if, if-else, Nested if-else, if-else if)5 min readScala | Loops(while, do..while, for, nested loops)5 min readBreak statement in Scala3 min readScala | Literals4 min readOOP ConceptsClass and Object in Scala5 min readInheritance in Scala5 min readOperators in Scala11 min readScala Singleton and Companion Objects3 min readScala Constructors4 min readScala | Polymorphism5 min readScala | Multithreading3 min readScala this keyword2 min readMethodsScala | Functions - Basics3 min readAnonymous Functions in Scala2 min readScala | Closures3 min readRecursion in Scala4 min readMethod Overloading in Scala5 min readMethod Overriding in Scala8 min readLambda Expression in Scala4 min readScala Varargs2 min readStringsScala String4 min readScala | String Interpolation3 min readScala | StringContext2 min readRegular Expressions in Scala5 min readStringBuilder in Scala4 min readScala PackagesPackages In Scala4 min readScala | Package Objects3 min readChained Package Clauses in Scala3 min readFile Handling in Scala3 min readScala TraitScala | Traits7 min readScala | Sealed Trait4 min readScala | Trait Mixins3 min readTrait Linearization in Scala5 min readCollectionsScala Lists5 min readScala ListBuffer6 min readListSet in Scala6 min readScala Map5 min readScala | Arrays6 min readScala | ArrayBuffer4 min readScala | Tuple5 min readSet in Scala | Set-13 min readSet in Scala | Set-27 min readBitSet in Scala5 min readHashSet In Scala4 min readStack in Scala3 min readHashMap in Scala3 min readTreeSet in Scala4 min readIterators in Scala5 min readScala | Option3 min read Like