ExternalAnnotations icon indicating copy to clipboard operation
ExternalAnnotations copied to clipboard

Strilanc.Value.May<T>.Match() - Must never use null as second parameter

Open jongleur1983 opened this issue 6 years ago • 0 comments

the May<T> type from the Strilang.Value package has two overloads for the Match() function.

  1. May<T>.Match<T, TOut>(Func<T, TOut> valueProjection, Func<TOut> alternativeFunc)
  2. May<T>.Match<T, TOut>(Func<T, TOut> valueProjection, TOut alternativeValue)

The first variant must not be called with alternativeFunc being null. The second may be called with null, but if written as plain code, using null here the compiler usually resolves it to the first variant, and by that failing at runtime.

Project on GitHub: https://github.com/Strilanc Package in NuGet: https://www.nuget.org/packages/Strilanc.Value.May

jongleur1983 avatar Aug 13 '18 08:08 jongleur1983