DigitecGalaxus / Galaxus.Functional

A package bringing popular functional abstractions (e.g. Option or Result) to C#.
Other
37 stars 12 forks source link

removed unwrap or default and replaced with to nullable #29

Closed NoelWidmer closed 2 years ago

NoelWidmer commented 2 years ago

UnwrapOrDefault() has been removed.

ToNullable() existed for structs already. Now it has also been added for classes. Classes and structs are therefore more alike with this change. ToNullable() for classes should also cover most use cases where UnwrapOrDefault() was used. A new extension class was required to work around overload issues.

If UnwrapOrDefault() was actually used to get the default value of a struct (which I don't think was done very often). We will now need to do: UnwrapOr(default); That doesn't seem like a bad alternative at all. So I don't think we are loosing anything by removing it.