Sometimes try to get away from your girlfriend, hiding behind the screen of your computer. However, I find that Scala is sometimes just like my girlfriend ...
This displays the intersection between the two lists:
val boys = List(Person("John"), Person("Kim"), Person("Joe"), Person("Piet"), Person("Alex"))
val girls = List(Person("Jana"), Person("Alex"), Person("Sally"), Person("Kim"))
println("Unisex names: " + boys.intersect(girls))
This does absolutely nothing:
val boys = List(Person("John"), Person("Kim"), Person("Joe"), Person("Piet"), Person("Alex"))
val girls = List(Person("Jana"), Person("Alex"), Person("Sally"), Person("Kim"))
println("Unisex names: " + boys intersect girls)
There are no compiler warnings, and the statement does not output anything to the console. Can someone please explain gently (I have a hangover) why this is so.
source
share