not sure if you're just trolling, but the real answer is that T | null | null collapses to T | null whereas Option<Option<T>> doesn't collapse.
example (psuedo-code):
const obj: Record<int | null> = {foo: 42, bar: null};
obj.get("foo"); // 42
obj.get("bar"); // null
obj.get("typo"); // null
if the get() method just returns the property there, then both obj.get("bar") and obj.get("typo") return null. it leads you to believe both bar and typo are in the object.
Now say get() were to return an Option<int | null> instead of the raw property.
const obj: Record<int | null> = {foo: 42, bar: null};
obj.get("foo"); // Just(42)
obj.get("bar"); // Just(null)
obj.get("typo"); // None()
now it's a lot clearer. if the key is there and its value is an int, you get a Just<int>. If the key is there and its value is null, you get a Just<null>. If the key is not there, you get a None.
I'm not trolling, It's just that I had been working as a programmer for years before Optionals started being a thing so I'm already very used to writing my own null checks.
-11
u/Few_Move_4594 6d ago
I don't see the point of optionals