Skip to content

T_CodeJam_Option_1

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

Option(T) Class

Represents an optional value.

Inheritance Hierarchy

System.Object
  CodeJam.Option(T)
    CodeJam.Option(T).None
    CodeJam.Option(T).Some
Namespace: CodeJam
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public abstract class Option<T> : IOption<T>, 
	IEquatable<Option<T>>

VB

Public MustInherit Class Option(Of T)
	Implements IOption(Of T), IEquatable(Of Option(Of T))

F#

[<AbstractClassAttribute>]
type Option<'T> =  
    class
        interface IOption<'T>
        interface IEquatable<Option<'T>>
    end

Type Parameters

 

T
  The Option(T) type exposes the following members.

Constructors

 

Name Description
Protected method Option(T) Initializes a new instance of the Option(T) class
  Back to Top

Properties

 

Name Description
Public property HasValue Gets a value indicating whether the current object has a value.
Public property IsNone Gets a value indicating whether the current object does not have a value.
Public property IsSome Gets a value indicating whether the current object has a value.
Public property Value Gets the value of the current object.
  Back to Top

Methods

 

Name Description
Public method Equals(Object) Indicates whether this instance and a specified object are equal. (Overrides Object.Equals(Object).)
Public method Equals(Option(T)) Indicates whether the current object is equal to another object of the same type.
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Returns the hash code for this instance. (Overrides Object.GetHashCode().)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns the fully qualified type name of this instance. (Overrides Object.ToString().)
  Back to Top

Operators

 

Name Description
Public operatorStatic member Equality Equality operator.
Public operatorStatic member Explicit(Option(T) to T) Extracts value from option
Public operatorStatic member Implicit(T to Option(T)) Creates a new object initialized to a specified value.
Public operatorStatic member Inequality Unequality operator.
  Back to Top

Extension Methods

 

Name Description
Public Extension Method Do(T) Calls someAction if option has value, and noneAction otherwise. (Defined by Option.)
Public Extension Method GetValueOrDefault(T)(T) Overloaded.
Returns value of option, or defaultValue if option hasn't it. (Defined by Option.)
Public Extension Method GetValueOrDefault(T, TResult)(Func(IOption(T), TResult), Func(TResult)) Overloaded.
Calls someSelector if option has value, and noneSelector otherwise. (Defined by Option.)
Public Extension Method With(T, TResult)(Func(T, TResult)) Overloaded.
Converts option value to another option with selectFunc. (Defined by Option.)
Public Extension Method With(T, TResult)(Func(T, TResult), TResult) Overloaded.
Converts option value to another option with selectFunc. (Defined by Option.)
Public Extension Method With(T, TResult)(Func(T, TResult), Func(TResult)) Overloaded.
Converts option value to another option with selectFunc. (Defined by Option.)
  Back to Top

See Also

Reference

CodeJam Namespace

Clone this wiki locally