O'Reilly logo

Learning Play! Framework 2 by Andy Petrella

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

Iterating over a sequence

Scala fits pretty well with list manipulations. Indeed, it facilitates their usage by defining a lot of methods that enable a lot of behaviors, such as filtering elements or grouping them based on an aggregation value. There are tons of such methods, and actually, if we need something to do something with a sequence, it should already be defined at http://www.scala-lang.org/api/current/index.html#scala.collection.Seq.

In the coming sections, we'll cover the most useful sequences when building Scala templates. First of all, let me just point to the fact that in Scala, when we think List we mean Seq.

Function – foreach

The foreach method provides a way to iterate over a sequence and apply a given function to each item. In ...

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