loader image

Create Scala Project on Intellij with Scala Worksheets | Scala

Scala is a  a multi-paradigm language that supports both functional and object-oriented programming with a growing community and many useful features Scala worth learning, and it has been adopted by big enterprises such as Linkedin , Twitter, and many others.

When you start experimenting Scala you can use Scala interactive REPL (Read Evaluate Print Loop) shell which will be a good option, but in case you need to experiment with a bigger block of codes re-editing and debugging on the shell will not be the best option for you, in this case we can use IDE such as Intellij IDE to start writing bigger blocks of code.

Intellij provides Scala Worksheets which will allow you to write Scala codes in interactive mode the same as you do in REPL shell, but with the use of editor which will make it so easy to edit and debug your code, especially with auto complete feature it will make writing Scala code a lot easier, in this article we will learn how to setup Scala project in Intellij and use Scala worksheets.

1- Open Intellij, click on Create New Project

2- Select Scala project, then select IDEA as project type

3- Enter Project Name, Project location, JDK version, and Scala SDK, if you don’t have current Scala SDK installed you can click on Create
Intellij will open a list of available Scala SDKs you can choose from, and when project starts Intellij will download Scala SDK for you,
then click on Finish

4- When project opens, right-click on src folder then New, then Scala Worksheet, you can choose Scala Class to create a Scala class or Scala Object, but in our case we need to create worksheet to experiment interactively

5- Enter a name for the worksheet

6- Scala worksheet will not be interactive by default, to make it interactive, click on settings icon, then choose check on Interactive Mode option for both the current worksheet and check it as the default option for future worksheets

7- Now we can start writing Scala code, when you write a line of code then press Enter Intellij will evaluate the line immediately and show the results on the right side of the screen

Facebook
Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Unlimited access to educational materials for subscribers

Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Tutor LMS website.
Hi, Welcome back!
Forgot?
Don't have an account?  Register Now