Skip to Content
Scala Reactive Programming
book

Scala Reactive Programming

by Rambabu Posa
February 2018
Intermediate to advanced
552 pages
13h 46m
English
Packt Publishing
Content preview from Scala Reactive Programming

Scala map() function

It is now a good time to understand how the map() function works in Scala. It's the same for all Scala containers such as Collections, Monads, and more. It is defined as shown in the following example in all Scala container classes:

final def map[B](f: (A) ⇒ B): C[B] 

Here, C is a Scala container class such as List, Option, Try, Future, and so on.

The map() function takes a function f as an argument. The function f is defined as f: A => B that means it takes the element A as input, processes it and outputs element B.

Here, A and B are of the same type or may be different types.

When we apply this map() function on Container C, the map() function performs the following steps:

  1. Picks up the first element from Container ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Scala Programming Projects

Scala Programming Projects

Mikael Valot, Nicolas Jorand
Learning Scala

Learning Scala

Jason Swartz
Functional Programming in Scala

Functional Programming in Scala

Runar Bjarnason, Paul Chiusano

Publisher Resources

ISBN: 9781787288645Supplemental Content