Pointers.WeakPointer

(in ./Carbon/Pointers/WeakPointer.lua)

Stores a reference to an object without affecting its garbage collection. Provides an implicit copy barrier.


Methods

class public WeakPointer:New(any? value)

Returns WeakPointer

  • optional value: The value to initialize the pointer with.

Creates a new WeakPointer.


object public WeakPointer:Copy()

Returns WeakPointer

Copies the WeakPointer, but not the data it points to.


object public WeakPointer:Available()

Returns bool

Returns whether the data the WeakPointer is pointing to is still valid for access. If this returns false, the data was probably garbage collected.


object public WeakPointer:Get()

Returns any?

Returns the value currently pointed to by the WeakPointer. Use WeakPointer:Available() first to make sure the data is still valid.


object public WeakPointer:Set(any? value)

Returns void

  • optional value: The value to initialize the pointer with.

Sets a new value for the WeakPointer.


Properties

[none]