4 ms·
"x" could be of a nullable type.
by lomnakkus 10y ago
"x" could be of a nullable type.
- recursive 10y agoAnd the result of the entire expression is still nullable. I'm not seeing any problem.
- lomnakkus 10y agoHm. What do you think "42 + null" is?
- recursive 10y agoAccording to c# (the language I'm talking about) I think it's null. That seems correct to me. Arithmetic on null operands logically seems to have a null result to me. I'm not sure what you're getting at. https://dotnetfiddle.net/nQoEKu https://dotnetfiddle.net/nQoEKu
- lomnakkus 10y agoThat's OK, I.. guess. I don't think I should even be allowed to ask the question because it's an absurd question[1]. Does that position make sense to you? [1] Not for frivolous reasons. It's almost always nonsensical to ask this type of question with "null" values. For the sensical cases we have Maybe/Option.
- recursive 10y agoI think I see what you want now. In order to get the value out, you'd have to use pattern matching or a type guard or something, inside of which you'd know there was a value. That makes sense to me too. But compared to Maybe, a null-safe member accessing operator, along with null-lifted operators seems nearly as good from my point of view.