HH\Lib\Ref
Wrapper class for getting object (byref) semantics for a value type
This is especially useful for mutating values outside of a lambda's scope.
In general, it's preferable to refactor to use return values or inout
parameters instead of using this class - however, a Ref of a Hack array
is generally preferable to a Hack collection - e.g. prefer Ref<vec<T>>
over Vector<T>.
C\reduce() and C\reduce_with_key() can also be used in some situations
to avoid this class.
Interface Synopsis
namespace HH\Lib;
final class Ref {...}
Public Methods
->__construct(T $value)->get(): T
Retrieve the stored value->set(T $new_value): void
Set the new value