Quantcast
Viewing latest article 10
Browse Latest Browse All 25

How to populate Scala collections with a Range

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.25, “How to Populate a Scala Collection with a Range”

Problem

You want to populate a List, Array, Vector, or other sequence with a Range.

Solution

Call the range method on sequences that support it, or create a Range and convert it to the desired sequence.

read more


Viewing latest article 10
Browse Latest Browse All 25

Trending Articles