예제 #1
0
 /// <summary>
 /// Constructs a new optional using the some value safety
 /// </summary>
 /// <param name="value"></param>
 public Option(Some <TVal> value)
 {
     this._value   = value;
     this.HasValue = true;
     _initialized  = true;
 }
예제 #2
0
 /// <inheritdoc />
 public bool Equals(Some <TVal> other) =>
 EqualityComparer <TVal> .Default.Equals(_value, other._value) && _initialized == other._initialized;
예제 #3
0
 /// <summary>
 /// Return the value if present or a fixed default
 /// </summary>
 /// <param name="default"></param>
 /// <returns></returns>
 public TVal SomeOrDefault(Some <TVal> @default)
 => this.HasValue ? this._value : ~@default;