Is there any way to put a if inside a match case in scala?
Something like this:
def createSchedules(listTask: List[TaskOrder], physicalResources: List[Physical], humanResources: List[Human], previousTime: Duration): List[TaskSchedule] = listTask match {
case TaskOrder(id, time, physicalRes, order) :: t =>
val taskScheduleHumanResources = setHumanResources(physicalRes, humanResources)
if (physicalRes != null)
new TaskSchedule(
order,
order.getProduct(),
Task(id, time, physicalRes),
physicalRes,
taskScheduleHumanResources,
order.quantity,
previousTime,
previousTime + time) :: createSchedules(t, physicalRes, humanResources, previousTime + time)
case Nil => Nil
}
Doing that I get an error saying:
type mismatch; found : Unit required: List[Objects.TaskSchedule]
What would be the best way to do it?
Aucun commentaire:
Enregistrer un commentaire