Intellij IDEA lets you create a Scala worksheet that enables you to evaluate your Scala code results in a special view of the Scala editor.
1. Creating Scala Worksheet
To create a Scala Worksheet, right-click on your project and selectNew→Scala Worksheet:
In the New Scala Worksheet window type a name of your Scala worksheet and clickOK.
As a result, a file with .sc extension opens. Now you can enter your code.
2. Running Scala Worksheet
You can enter your code and press to see the results. You can clear theMake projectcheck box to improve evaluation performance. In this case, the automatic checking of project's changes is disabled.
The results appear in the view on the right side of your code.
A Scala object could be also evaluated. Let's see the following code and the results:
You can fold the output without affecting your code on the left side and expand only that block output that matches a specific statement.
3. Removing Worksheet's Results
You can remove the worksheet's results easily by pressing icon.
4. Copying Actions
You can easily copy your code and evaluation results into one file by clicking icon.
5. Configuring Worksheet Settings
You can configure your worksheet's settings by selectingFile→Settings→Scala, on the main menu, and clickingWorksheet tab.
On the Worksheet tab, you can set the length for the line break of your results and the output cutoff limit.
You can also configure in what mode you want to run the worksheet.