looking for some solutions? You are welcome.

SOLVED: how shall I check that a Future is not null

Manu Chadha:

The following code returns a Future.

val findUserFuture: Future[Option[User]] = userRepo.findOne(userKeys) 

Then I process the Future

findUserFuture.flatMap {....}
.recover{...}

I suppose that recover will be called if flatMap throws an Exception. But what if findOne returns null? Is there a Scala specific way to check that findUserFuture is not null? I can I suppose do if(findUserFuture != null) but I am wondering is Scala provides some different way to check nulls



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent