|
|
|
|
|
by ahoka
3429 days ago
|
|
Optional types shine the best when you can chain them: BufferedImage avatar = users.getUser(userName)
.flatMap(User::getAvatarUri)
.flatMap(ImgIO::read)
.orElse(anonymousAvatar); I made this up, but I hope you see the point. Optional is just a fancy null pointer if you don't use it in a functional way. :-) |
|