Chapter 3: A Beginner's Tutorial To Using Functions In Scala

By Nadim Bahadoor | Last updated: July 14, 2017 at 12:39 pm

In this section, we will go over how to define and use functions in theĀ Scala programming language.


If you recall from the Scala Introduction tutorial, Scala is both an Object Oriented and Functional programming language. If you are new to functional programming - don't worry :) this chapter will help you learn about the various ways you can define and use functions in Scala.


Throughout the tutorials we will use the popular IntelliJ IDEA which we've setup in Chapter 1. I hope that by now you are more comfortable using IntelliJ. If not, feel free to review the previous tutorials fromĀ Chapter 1!


In this chapter, we will provide tutorials on the topics below. If none of these make any sense right now, that's OK :)

  • Function introduction
  • Function with an Option parameter
  • Function with implicit parameters
  • Function which itself is implicit
  • Function which specifies type parameters
  • Function which accepts variable arguments
  • Function which can be defined as operators
  • Function which accepts parameter groups
  • Function which takes another function as parameter - Higher Order Functions
  • Function which accepts a callback function as its parameter
  • Function which are defined as values
  • Function which can be composed together
  • Function which is tail recursive
  • Function which can be partial
  • Function which can be nested within another function

So let's get started!

Nadim Bahadoor on FacebookNadim Bahadoor on GithubNadim Bahadoor on LinkedinNadim Bahadoor on Twitter
Nadim Bahadoor
Senior Principal Engineer | Elsevier
Founder of I have over 10 years of experience in building large scale real-time trading systems in the financial industry. Passionate about Distributed Systems, Scala, Big Data and Functional Programming. Stay in touch for upcoming tutorials!

Share this article on

  • Divus Iuilius

    How is it possible to compile a scala file that is throwing errors? But, it will compile and run without errors! If I simply run the scala file with the *.scala extension, I get an error. But If I compile and then run the file without the *.scala extension I get not error and runs without a hitch.

    “C:Users`Desktoptax.scala:38: error: not found: value findTaxNum
    val returnedStatetax: Double = findTaxNum.getStatetax(state)
    ^ I’m totally perplexed. I don’t get this error if I compile and run.