Re: ObservableValue.map special-cases the null value

2023-05-18 Thread John Hendrikx
On 18/05/2023 19:05, Michael Strauß wrote: Hi John, the `isPresent()` and `isEmtpy()` methods don't feel entirely natural to me. I think the problem is that Optional has slightly different semantics compared to ObservableValue. An Optional either has a value, or it doesn't. The "it doesn't have

Re: ObservableValue.map special-cases the null value

2023-05-18 Thread Michael Strauß
Hi John, the `isPresent()` and `isEmtpy()` methods don't feel entirely natural to me. I think the problem is that Optional has slightly different semantics compared to ObservableValue. An Optional either has a value, or it doesn't. The "it doesn't have a value" state doesn't feel exactly equivalen

Re: ObservableValue.map special-cases the null value

2023-05-16 Thread John Hendrikx
Hi Michael, As you're only trying to map to true/false, it is a bit ugly to do this I suppose:   nullableValue.map(x -> true).orElse(false); I've encountered situations like these before, where you only want to know about the presence of a value, and don't care what the value is.  If th

ObservableValue.map special-cases the null value

2023-05-16 Thread Michael Strauß
I'm trying to map an ObservableValue such that `null` is mapped to `false` and any other value is mapped to `true`. The following line of code should do the trick: ObservableValue mappedValue = nullableValue.map(x -> x != null); It turns out that this doesn't work, since `map` doesn't pass `null`