Book Image

Learning Concurrent Programming in Scala

By : Prokopec
5 (1)
Book Image

Learning Concurrent Programming in Scala

5 (1)
By: Prokopec

Overview of this book

This book is a must-have tutorial for software developers aiming to write concurrent programs in Scala, or broaden their existing knowledge of concurrency. This book is intended for Scala programmers that have no prior knowledge about concurrent programming, as well as those seeking to broaden their existing knowledge about concurrency. Basic knowledge of the Scala programming language will be helpful. Readers with a solid knowledge in another programming language, such as Java, should find this book easily accessible.
Table of Contents (18 chapters)
Learning Concurrent Programming in Scala
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Scala collections in a nutshell


The Scala collections module is a package in the Scala standard library that contains a variety of general-purpose collection types. Scala collections provide a general and easy-to-use way of declaratively manipulating data using functional combinators. For example, in the following program, we use the filter combinator on a range of numbers to return a sequence of palindromes between 0 and 100,000; that is, numbers that are read in the same way in both the forward and reverse direction:

(0 until 100000).filter(x => x.toString == x.toString.reverse)

Scala collections define three basic types of collections: sequences, maps, and sets. Elements stored in sequences are ordered and can be retrieved using the apply method and an integer index. Maps store key-value pairs and can be used to retrieve a value associated with a specific key. Sets can be used to test the element membership with the apply method.

The Scala collection library makes a distinction between...