O'Reilly logo

Scala Functional Programming Patterns by Atul S. Khot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A view to a collection

Databases have views. A database view works just like a table; however, the table never exists. It is just an illusion. A view is only a stored query, which is run when the view name is referenced:

Mysql> CREATE VIEW first_last AS SELECT first_name, last_name FROM NAMES WHERE last_name LIKE ('k%');
mysql> SELECT first_name FROM first_last;

The view first_last query is backed by the result set of a query, on a real table, NAMES. We can select only the columns of interest and apply some transformations on them.

Scala collection views are similar. We will soon be giving a close look to functional transformation. However, to get a taste, the following is an example:

We need to assign a temporary password to a user. We have a list ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required