News for hackers. Stuff that matters.
Re:Go generics draft design: building a hashtable by alkonaut on Wednesday June 17, 2020 @06:16PM (#23557465)
I use Option<T> types very happily in C# without sum types. Most of what would be pattern matching can be done with just methods.

    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.

There are no comments on this comment yet.