Given that the mapper function returns null, the resulting Option is Some(null) instead of None()
Actual map function implementation is like this
@Override
default <U> Option<U> map(Function<? super T, ? extends U> mapper) {
Objects.requireNonNull(mapper, "mapper is null");
return isEmpty() ? none() : some(mapper.apply(get()));
}
Shouldn't it be like
@Override
default <U> Option<U> map(Function<? super T, ? extends U> mapper) {
Objects.requireNonNull(mapper, "mapper is null");
return isEmpty() ? none() : Option.of(mapper.apply(get()));
}
Please see #1852 #1636 and http://blog.javaslang.io/the-agonizing-death-of-an-astronaut/
Thanks @ruslansennov clear enough with references explanations.
Regards.
Most helpful comment
Please see #1852 #1636 and http://blog.javaslang.io/the-agonizing-death-of-an-astronaut/