Provides types for returning values without nulls. Provides three classes of the interface IOption<T>: * Some<T> is a class for holding a valid value. It holds one readonly value which is set in the constructor. This is to immutable. * None<T> is a readonly struct for holding nothing. This is replacing null. * Err<T> class holds a readonly exception (set in constructor) as ex which can be used for returning errors without throwing them until you need. IOption<T> provides one public method: bool HasValue(out T value) which can be used to check if the returned type is a Some<T>, and if it is, to get the value in the out parameter. Use this with care, as if it returns false, value will be default, which is often null. Best to define the out parameter inline to prevent using it wrongly. eg: if(option.HasValue(out string answer)){ //do stuff with answer here}
License
—
Deps
0
Install Size
—
Vulns
✓ 0
Published
Aug 28, 2018
$ dotnet add package OptionReturnValues_balfourcraigNo README available.