A Look at the Scala Main Class
Check out this quick look at adding a main class in Scala.
Join the DZone community and get the full member experience.Join For Free
Adding a main class in Scala is something that I always end up searching online, so next time, it shall be through this blog post! Let's get started.
You may also like: [DZone Refcard] Getting Started With Scala
Go for the Extends App Option
One way is to add a
MainClass by extending the
Appclass. Everything else that gets executed on that block is part of the "main" function.
Then, you can access the arguments since they are a variable on the
Add a Main Method
This is the most Java familiar option:
As expected, you receive the program arguments through the function arguments.
Hope you enjoyed! Please share your thoughts and questions in the comments section!
Published at DZone with permission of Emmanouil Gkatziouras, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.