Created
August 11, 2014 08:56
-
-
Save iulianu/e2d668bafdba87b9e87b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val kidsNames = List("John", "George", "Victor") | |
kidsNames: List[String] = List(John, George, Victor) | |
scala> val beatlesNames = List("John", "Ringo", "Paul", "George") | |
beatlesNames: List[String] = List(John, Ringo, Paul, George) | |
scala> kidsNames.intersect(beatlesNames) | |
res2: List[String] = List(John, George) | |
// Looks reasonable! | |
// But what if we do... | |
scala> val beatlesNames = List(Option("John"), Option("Ringo"), Option("Paul"), Option("George")) | |
beatlesNames: List[Option[String]] = List(Some(John), Some(Ringo), Some(Paul), Some(George)) | |
scala> kidsNames.intersect(beatlesNames) | |
res1: List[String] = List() | |
// Boom, silent failure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment