Extension Methods
Exercise 1
val cities = List("London", "Paris", "Lisbon", "Berlin")
Create a list of cities:
- In an object create an extension method
printto theStringclass. - In another object create a second extension method
printto the String that prints in ALL-CAPS - Choice which
printmethod you will use with animport
Create a case class CapitalCity with a city and a country
Create a list of capital cities
- Create an extension method
printto the CapitalCity companion object - Print the list of capital cities
Exercise 2
Create a case class Person with a name and age
Create a list of persons
- Create an extension method
printto the Person companion object. - In another object create an extension method
printto the Persion that prints in ALL-CAPS - Choice which
printmethod you will use with animport