- changed status to resolved
The Option.map(Function) accepts a null as a return value from the Function#apply resulting in Some(null)
Issue #12
resolved
The Option.map(Function) accepts a null as a return value from the Function#apply resulting in Some(null).
For example the following code results in Some(null):
Option<String> someOption = some("");
someOption.map(
new Function<String, String>() {
@Nullable @Override
public String apply(@Nullable final String str) {
return null;
}
}
);
I believe this should result in a NPE or Option.none().
Comments (2)
-
-
reporter Ok, thanks for clarifying that.
- Log in to comment
This is deliberate, and won't change. It in fact must happen to preserve the Functor laws so that composing two functions into one and mapping that is the same as mapping each function in succession.
The behavior you want is provided by:
We could potentially provide a null aware alternative convenience for the above.