September 2018
Intermediate to advanced
398 pages
9h 43m
English
Now that all our tests are green, we can implement the main method. The implementation becomes trivial as all the code is already in the test:
object Main extends App { val persons = List( Person(firstName = "Akira", lastName = "Sakura", age = 12), Person(firstName = "Peter", lastName = "Müller", age = 34), Person(firstName = "Nick", lastName = "Tagart", age = 52)) val adults = Person.filterAdult(persons) val descriptions = adults.map(p => p.description).mkString("\n\t") println(s"The adults are \n\t$descriptions")}
The first thing is to define a list of Person, so that Person.filterAdult() is used to remove all the persons, not the adults. The adults variable is a list of Person, but I would like to transform ...
Read now
Unlock full access