transformer

Scala Vector transformer methods (syntax, examples)

This page contains a large collection of examples of how to use Scala Vector class transformer methods.

Transformer methods

A transformer method is a method that constructs a new collection from an existing collection.

How to transform Scala collections with for/yield

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.13, “How to Transform One Scala Collection to Another with for/yield”

Back to top

Problem

You want to create a new collection from an existing collection by transforming the elements with an algorithm.

Back to top

Solution

Use the for/yield construct and your algorithm to create the new collection. For instance, starting with a basic collection:

Table of Contents

  1. Problem
  2. Solution
Back to top