Skip to content

M_CodeJam_Option_GetValueOrDefault__2

Andrew Koryavchenko edited this page Jun 17, 2018 · 5 revisions

Option.GetValueOrDefault(T, TResult) Method (IOption(T), Func(IOption(T), TResult), Func(TResult))

Calls someSelector if option has value, and noneSelector otherwise.

Namespace: CodeJam
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static TResult GetValueOrDefault<T, TResult>(
	this IOption<T> option,
	Func<IOption<T>, TResult> someSelector,
	Func<TResult> noneSelector
)

VB

<ExtensionAttribute>
Public Shared Function GetValueOrDefault(Of T, TResult) ( 
	option As IOption(Of T),
	someSelector As Func(Of IOption(Of T), TResult),
	noneSelector As Func(Of TResult)
) As TResult

F#

[<ExtensionAttribute>]
static member GetValueOrDefault : 
        option : IOption<'T> * 
        someSelector : Func<IOption<'T>, 'TResult> * 
        noneSelector : Func<'TResult> -> 'TResult 

Parameters

 

option
Type: CodeJam.IOption(T)
Option instance to match.
someSelector
Type: System.Func(IOption(T), TResult)
Function if value exists.
noneSelector
Type: System.Func(TResult)
Function if no value.

Type Parameters

 

T
Type of value
TResult
Type of result

Return Value

Type: TResult
Result of matched function

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IOption(T). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also

Reference

Option Class
GetValueOrDefault Overload
CodeJam Namespace

Clone this wiki locally