This commit is contained in:
Jerry Lee
2019-01-09 19:39:42 +08:00
parent b87df45111
commit 46a69a6fec

View File

@@ -0,0 +1,8 @@
原文链接: [How Optional Breaks the Monad Laws and Why It Matters](https://www.sitepoint.com/how-optional-breaks-the-monad-laws-and-why-it-matters/) - _Marcello La Rocca_2016-09
# `Optional`是如何打破了`Monad`定律以及为什么这是重要的
`Java 8`引入了`Lambda``Stream`这2个都是期待已久的功能。另一个引入的是`Optional`,在`Stream`管线(`pipeline`)的结尾可能没有元素返回时,用来避免`NullPointerException`。在其它语言中,『可能有值或无值』这样的类型比如`Optional`都是表现良好的`Monad`,但在`Java``Optional`却并不是。这点对于我们的日常开发是重要的。