Get SpatialOS

Sites

Menu

Option<T> Struct

Namespace: Improbable.Gdk.Core
GDK package: Core
Source

An implementation of Option which is compatible with Unity's ECS.

Type parameters

T : The contained type in the Option.

Inheritance

IEquatable<Option<T>>

Notes

  • This is required because bool is not blittable by default.


Static Fields

Empty Source
readonly Option<T> Empty


Properties

HasValue Source
BlittableBool HasValue { get; }

True if the Option contains a value, false if not.
Value Source
T Value { get; }

Returns the value contained inside the Option.

Exceptions:


Constructors

Option Source
Option(T value)

Constructor for an option.

Parameters
  • T value : The value to be contained in the option

Exceptions:


Methods

TryGetValue Source
bool TryGetValue(out T outValue)

Attempts to get the value contained within the Option.

Returns:
A bool indicating success.

Parameters
  • out T outValue : When this method returns, contains the value contained within the Option if the Option is non-empty, otherwise the default value for the type of the outValue parameter.
GetValueOrDefault Source
T GetValueOrDefault(T defaultValue)

Gets the value within the Option or the provided default value if the Option is empty.

Returns:
The value contained within the Option or the provided value.

Parameters
  • T defaultValue : The default value to return if the Option is empty.
Equals Source
bool Equals(Option<T> other)

Parameters


Overrides

Equals Source
override bool Equals(object other)

Parameters
  • object other :
GetHashCode Source
override int GetHashCode()

ToString Source
override string ToString()


Operators

operator== Source
bool operator==(Option<T> a, Option<T> b)

Parameters
operator!= Source
bool operator!=(Option<T> a, Option<T> b)

Parameters
operator Option<T> Source
implicit operator Option<T>(T value)

Parameters
  • T value :
operator T Source
implicit operator T(Option<T> option)

Parameters

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums