by weberc2 · 6y ago · 0 comments
Car c = maybeCar.GetValueOr(CreateCar()) // inline fallback
maybeDog.Do(d => b.Bark()) // only performs call if present
Sailboat s = mybeBoat.As<SailBoat>() // none unless of correct subtype
And so on.
With nullable reference types C# now has a builtin alternative to this, but it has worked we’ll for many years.