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 ...

Get Scala Functional Programming Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.