Ref<T>#
A mutable box that holds one value of type T. A method that reports a result through an out parameter writes into it. In the public API that method is Patch#tryGetValue. Create an empty one with new Ref<>(), pass it in, then read value.
Declaration#
;
Constructors#
Ref()#
public
Creates a holder with value set to null.
Ref(T value)#
public
Creates a holder with value already set.
| Name | Type | Description |
|---|---|---|
value |
T |
The starting value. Can be null. |
Fields#
value#
public T value
The held value. It's a plain public field: read it and assign it directly, with no getter or setter. Ref doesn't override equals, hashCode or toString, so two holders with the same value aren't equal.
Example#
;
Related#
Patch-tryGetValuewrites into aRefSortedDict- anothertryGetValuethat takes aRef- Records, ids and dates - reading patch fields