April 2018
Intermediate to advanced
396 pages
11h 8m
English
The first thought that might come into your head is to change the classes and make the properties variable. Here is how our case classes would change:
case class Country(var name: String, var code: String)case class City(var name: String, var country: Country)case class Address(var number: Int, var street: String, var city: City)case class Company(var name: String, var address: Address)case class User(var name: String, var company: Company, var address: Address)
After this, using these classes will be as easy as this:
object UserBadExample { def main(args: Array[String]): Unit = { val uk = Country("United Kingdom", "uk") val london = City("London", uk) val buckinghamPalace = Address(1, "Buckingham Palace Road",
Read now
Unlock full access