NullablePointer[A: A]

[Source]

A NullablePointer[A] is used to encode a possibly-null type. It should only be used for structs that need to be passed to and from the C FFI.

An optional type for anything that isn't a struct should be encoded as a union type, for example (A | None).

struct ref NullablePointer[A: A]

Constructors

create

[Source]

This re-encodes the type of that from A to NullablePointer[A], allowing that to be assigned to a field or variable of type NullablePointer[A]. It doesn't allocate a wrapper object: there is no containing object for that.

new ref create(
  that: A)
: NullablePointer[A] ref^

Parameters

  • that: A

Returns

none

[Source]

This returns a null pointer typed as a NullablePointer[A].

new ref none()
: NullablePointer[A] ref^

Returns

Public Functions

apply

[Source]

This re-encodes the type of this from NullablePointer[A] to A, allowing this to be assigned to a field of variable of type A. If this is a null pointer, an error is raised.

fun box apply()
: this->A ?

Returns

  • this->A ?

is_none

[Source]

Returns true if this is null (ie apply would raise an error).

fun box is_none()
: Bool val

Returns

© 2016-2020, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/builtin-NullablePointer