Пример #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;