Title: Filter A Sequence
Slug: filter_a_sequence
Summary: Filter A Sequence Using Scala.
Date: 2017-01-03 12:00
Category: Scala
Tags: Basics
Authors: Chris Albon
If you want to learn more, check out Scala Cookbook and Programming in Scala.
In [20]:
// Create an array that contains arrays with first and last names
val ages = Array(42,25,28,38,58,63,23,458,2569,584,25,25,878)
In [21]:
ages.filter(_ < 100)
Out[21]:
In [22]:
ages.filter(_ >= 100)
Out[22]:
In [23]:
ages.filter(_ % 2 == 0)
Out[23]: