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 Select

Select<T, TResult>(Maybe<T>, Func<T, Maybe<TResult>>)

Converts a Maybe<T> to a Maybe{TResult} using the function provided.

Declaration
public static Maybe<TResult> Select<T, TResult>(this Maybe<T> maybe, Func<T, Maybe<TResult>> predicate)
Parameters
Type Name Description
Maybe<T> maybe

The maybe to convert.

Func<T, Maybe<TResult>> predicate

A function that converts the value of maybe.

Returns
Type Description
Maybe<TResult>

A Maybe{T} instance that is either nothing, or the result of the predicate function.

Type Parameters
Name Description
T

The type of value contained in the maybe instance.

TResult

The type of value in the returned Maybe<T> instance.

Remarks

If maybe is nothing then an empty instance of Maybe{TResult} is returned, otherwise the predicate function is used to calculate the return value.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if predicate is null.

Select<T, TResult>(Maybe<T>, Func<T, TResult>)

Converts a Maybe<T> to a Maybe{TResult} using the function provided.

Declaration
public static Maybe<TResult> Select<T, TResult>(this Maybe<T> maybe, Func<T, TResult> predicate)
Parameters
Type Name Description
Maybe<T> maybe

The maybe to convert.

Func<T, TResult> predicate

A function that converts the value of maybe to a value of TResult.

Returns
Type Description
Maybe<TResult>

A Maybe{T} instance that is either nothing, or the result of the predicate function.

Type Parameters
Name Description
T

The type of value contained in the maybe instance.

TResult

The type of value in the returned Maybe<T> instance.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if predicate is null.

Select<T, TResult>(IEnumerable<Maybe<T>>, Func<T, Maybe<TResult>>)

Converts an of Maybe<T> values to a set of Maybe{TResult} values.

Declaration
public static IEnumerable<Maybe<TResult>> Select<T, TResult>(this IEnumerable<Maybe<T>> source, Func<T, Maybe<TResult>> predicate)
Parameters
Type Name Description
IEnumerable<Maybe<T>> source

The to operate on.

Func<T, Maybe<TResult>> predicate

A function that converts a {T} value to a Maybe{TResult}.

Returns
Type Description
IEnumerable<Maybe<TResult>>

A set of Maybe{TResult} values.

Type Parameters
Name Description
T

The type of value contained with the Maybe<T> instances in the source argument.

TResult

The type of value contained in the Maybe<T> instances returned.

Remarks

If source is null then an empty set is returned.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if predicate is null.

Back to top Copyright (c) 2017 Troy Willmot