3 ms·
Optionals without do notation will be a bad time.
by pharmakom 5y ago
Optionals without do notation will be a bad time.
- LAC-Tech 5y agoWhat's do notation? I've used optionals in many languages, and this is the first I've heard of it. What else do you really need except map and... flatMap (aka `then` aka `and_then` aka `>>=` aka `bind`).
- uryga 5y agohttps://en.m.wikibooks.org/wiki/Haskell/do_notation https://en.m.wikibooks.org/wiki/Haskell/do_notation rough analogy: `await` replaces `.then()`, do-notation replaces `.flatMap()`
- int_19h 5y agoC# has had Nullable<T> for many years before it got stuff like ?. and ?? that mostly covers this, and it was, well, tolerable.
- BoorishBears 5y agoErgonomics sucked and a lot of people didn't use them (or even know they existed!) because ergonomics sucked
- int_19h 5y agoFrom my work experience at the time, it was used pretty heavily in new codebases.
- BoorishBears 5y agoI mean the fact that they've been around since 2.0 but you saw it used heavily in new codebases says a lot doesn't it?
- int_19h 5y agoYou misunderstood - I saw them in codebases that were new back when .NET 2.0 was new. To be more precise, it was when .NET 3.5 was new (2008). That brought a lot of visibility to Nullable<T> because it was featured prominently in LINQ. But ?. didn't come until C# 6 (2014). I was wrong about ??, though - that one was added along with Nullable itself.