What should be used instead of someMethod in the following code to get correct results?
case class case class Employee(name: String, department: String, manager: Option[String])
def lookupByName(name: String): Option[Employee] = name match {
case "Joe" => Some(Employee("Joe", "Finances", Some("Julie")))
case "Mary" => Some(Employee("Mary", "IT", None))
case "Izumi" => Some(Employee("Izumi", "IT", Some("Mary")))
case _ => None
}
lookupByName("Joe").someMethod(_.department != "IT") == Some(Employee("Joe", "Finances", Some("Julie")))
lookupByName("Mary").someMethod(_.department != "IT") == None
lookupByName("Foo").someMethod(_.department != "IT") == None
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать