Skip to Content
Scala Reactive Programming
book

Scala Reactive Programming

by Rambabu Posa
February 2018
Intermediate to advanced
552 pages
13h 46m
English
Packt Publishing
Content preview from Scala Reactive Programming

Scala List

In the Scala Collection API, List is a LIFO-based immutable Collection which represents an ordered linked list (where LIFO stands for Last In First Out). It is available as scala.collection.immutable.List.

It has two implementation case classes, scala.Nil and scala.:: as shown here:

sealed abstract class List[+A] 
object List 
final case class :: extends List[B] 
case object Nil extends List[Nothing] 

Let's explore it with some examples:

scala> val numberList = List(1,2,3,4) numberList: List[Int] = List(1, 2, 3, 4) scala> number numberList numbersList scala> number numberList numbersList scala> numberList.map(x=> x.toString) res0: List[String] = List(1, 2, 3, 4) scala> val strList = "One" :: "Two" :: Nil strList: List[String] = List(One, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Scala Programming Projects

Scala Programming Projects

Mikael Valot, Nicolas Jorand
Learning Scala

Learning Scala

Jason Swartz
Functional Programming in Scala

Functional Programming in Scala

Runar Bjarnason, Paul Chiusano

Publisher Resources

ISBN: 9781787288645Supplemental Content