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 WhenNothing

WhenNothing<T>(Maybe<T>, Action)

Exectues the action only if source is empty.

Declaration
public static Maybe<T> WhenNothing<T>(this Maybe<T> source, Action action)
Parameters
Type Name Description
Maybe<T> source

A Maybe<T> to check for emptiness.

Action action

The action to execute if source is nothing.

Returns
Type Description
Maybe<T>

Returns source allowing for chanining of method calls.

Type Parameters
Name Description
T

The type of value contained within the maybe.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when action is null.

Back to top Copyright (c) 2017 Troy Willmot