Demystify Scala Functions


Scala is a functional programming language. So, functions are the basic building blocks in Scala. In any other programming language, learning about the function is as simple as learning one basic syntax. I mean, you just need to know the syntax to define a function. However, that approach does not work with Scala. I often see many confusions around Scala functions that makes it difficult for a beginner. I blame two things for causing this trouble.

  1. Optional components and flexible syntax.
  2. Jargons and Functional Programming concepts.

There are several optional components and flexible syntax. They often create much confusion. Then, there are a bunch of functional programming jargons. I have already tried to separate out some of the jargons in a separate article series for an introduction to functional programming. This article takes a systematic and step by step approach to eliminate all the confusions around Scala functions. In this article, I am going to cover following things.

  1. Basics of Scala functions
  2. Function Literals in Scala
  3. Function values
  4. Local Functions
  5. Variable length argument
  6. Default values and named arguments
  7. Scala placeholder syntax
  8. Higher Order functions
  9. Partially applied functions
  10. Function currying

So, with the stage set, let's take these concepts one by one.


Read Next

Basics of Scala functions | Function Literals in Scala | Function values | Local Functions | Variable length argument | Default values and named arguments | Scala Placeholder syntax | Higher Order functions | Partially applied functions | Function currying

By Prashant Pandey -



You will also like: