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:

Functional Programming

What is Functional Programming and why it is important?

Learning Journal

First Class Functions

Function is a first-class citizen in functional programming. What does it mean?

Learning Journal

Hadoop Security

Hadoop security implementation using Kerberos.

Learning Journal

Statements and Expressions

Statements and Expressions in Scala. How are they different?

Learning Journal

Lazy Evaluations

Evaluate the expression now vs evaluate it for the first use. Strict vs Lazy?

Learning Journal