Scala filter co jest nie tak?

0

// filter a list of vehicles by the given sunroofType

def filterVehiclesBySunroof(inputVehicles: List[Vehicle], sunroofType: String): List[Vehicle] = {
inputVehicles.filter(Vehicle => vehicle.sunroofType == sunroofType) ??????
}

// filter list of vehicles by the given sunroof type, possible values are AUTO, MANUAL or the option is None
// if the car doesn't have a sunroof
"filterVehiclesBySunroof" should {
"Return list of vehicles filtered by given sunroof value" in {
assert(filterVehiclesBySunroof(vehiclesEU, "AUTO").toSet == Set(Vehicle(70, "Jeep", 1, Some("AUTO"))))

1

A co jest nie tak?
Poza tym, że kod warto wstawić w znaczniki,
a to coś wyżej ma błędy składniowe.

0

inputVehicles.filter(Vehicle => Vehicle.sunroofType == sunroofType)

Expected :Set(Vehicle(70,Jeep,1,Some(AUTO)))
Actual :Set()

nie zwraca mi nic

3

Zabawię się we wróżkę. Porównujesz Option[String] (vehicle.sunroofType) ze String (sunroofType).

PS - poza tym polecam kurs uważnego czytania:
screenshot-20190925184627.png

1 użytkowników online, w tym zalogowanych: 0, gości: 1