Vavr: Option map function can result on a Some(null)

Created on 17 Feb 2017  路  2Comments  路  Source: vavr-io/vavr

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()));
    }
question 芦vavr-control禄

Most helpful comment

All 2 comments

Thanks @ruslansennov clear enough with references explanations.

Regards.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maystrovyy picture maystrovyy  路  3Comments

bhchandra picture bhchandra  路  3Comments

santiagopoli picture santiagopoli  路  6Comments

HiDAl picture HiDAl  路  3Comments

enelson picture enelson  路  5Comments