NuGet Package OptionReturnValues_balfourcraig

Provides types for returning values without nulls.
Provides three classes of the interface IOption:
* Some is a class for holding a valid value.

It holds one readonly value which is set in the constructor. This is to immutable.
* None is a readonly struct for holding nothing. This is replacing null.
* Err class holds a readonly exception (set in constructor) as ex which can be used for returning errors without throwing them until you need.

IOption provides one public method: bool HasValue(out T value) which can be used to check if the returned type is a Some, 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}.

Info

Version: 1.0.4
Author(s): balfourcraig
Last Update: Tuesday, August 28, 2018
.NET Fiddle: Create the first Fiddle
NuGet Url: https://www.nuget.org/packages/OptionReturnValues_balfourcraig


Install
Install-Package OptionReturnValues_balfourcraig
dotnet add package OptionReturnValues_balfourcraig
paket add OptionReturnValues_balfourcraig
OptionReturnValues_balfourcraig Download (Unzip the "nupkg" after downloading)





STATS

must-have-score

avg-downloads-per-day

2

days-since-last-release

172