handleFailure 함수에서 "attempt"변수를 알 수 있도록 다음 코드를 수정할 수 있습니까?필터/맵 작업에서 값을 찾을 수 없습니다.
def getLoginAttempts(username: String): Option[Long] = ...
getLoginAttempts(username) filter (attempts => attempts <= MAX_ATTEMPTS) map {
handleFailure(username, attempts)
} orElse sendNotification()
컴파일러 출력 => 찾을 수 없음 : 왜 단순히
val attempts = getLoginAttempts(username).getOrElse(0)
if(attempts >= MAX_ATTEMPTS) handleFailure(username, attempts) else sendNotifications()