Skip to content

Instantly share code, notes, and snippets.

Created November 20, 2021 08:23
What would you like to do?
concise if
fun generatePayrollFor(employeeName: String): Either<Problem, Payroll> {
return employeeService.findEmployeeByName(employeeName)
.flatMap { employee ->
if (employee != null) buildPayrollForEmployee(employee) else UserDoesNotExistProblem(employeeName).left()
}.tapLeft {"Could not fetch employee: ${it.message()}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment