Show / Hide Table of Contents
  • MaybeSharp
    • Maybe<T>
      • As
      • Bind
      • Cast
      • CompareTo
      • Equality
      • Equals
      • Explicit
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • HasValue
      • Implicit
      • Inequality
      • IsEmpty
      • LessThan
      • LessThanOrEqual
      • Maybe
      • Nothing
      • ToString
      • Value
  • MaybeSharp.Extensions
    • MaybeDictionaryExtensions
      • TryGetValue
    • MaybeExtensions
      • Coalesce
      • Or
      • Select
      • SelectMany
      • SelectNonempty
      • ToNullable
      • ValueOr
      • ValueOrException
      • WhenNothing
      • WhenSomething
      • Where
    • MaybeStringExtensions
      • TryParseBoolean
      • TryParseByte
      • TryParseChar
      • TryParseDateTime
      • TryParseDateTimeOffset
      • TryParseDecimal
      • TryParseDouble
      • TryParseInt
      • TryParseInt16
      • TryParseInt64
      • TryParseSingle
    • NullableExtensions
      • ToMaybe

Method Or

Or<T>(Maybe<T>, Maybe<T>)

Coalesces this value with another. If this value is empty, other is returned, otherwise this is returned.

Declaration
public static Maybe<T> Or<T>(this Maybe<T> source, Maybe<T> other)
Parameters
Type Name Description
Maybe<T> source

A Maybe{T} instance to coalesce.

Maybe<T> other

A second Maybe{T} instance to coalesce.

Returns
Type Description
Maybe<T>

Either source if it is not empty, otherwise other.

Type Parameters
Name Description
T

The sub-type of the Maybe{T} instances.

Remarks

Similar to the Coalesce<T>(Maybe<T>, IEnumerable<Maybe<T>>) method is lower allocation when using individual instances as no array or enumerale type needs to be created to pass the individual elements.

Back to top Copyright (c) 2017 Troy Willmot