Menu

keywords-ref

Will Pittenger

Forces a type to be a reference type. If the type is already a reference, you get a reference to a reference to the type. Can be applied to variables that are const, var, expression, return values as well as typealias declarations. If a formal parameter to a procedure or property was declared as ref, the name of the actual parameter must be preceded by ref as well. Not the same as out. See the out keyword page and [By value versus by reference] for details. If you need to combine ref with out, use a type alias. Can't be used in the same type as byvalue even with a type alias.

The sample below is for var, but other uses are similar. For more on what /TypeDescriptor/ can be, see Type descriptors.

\var\ [\ref\] [\readonly\] [\const\] /TypeDescriptor/ /identifier/

The next sample show the syntax for an actual parameter.

(\ref\ | \out\ | \byvalue\) /identifier/

Related

Wiki: Appendices-Terms-Type descriptors
Wiki: By value versus by reference
Wiki: Complex Statements
Wiki: Custom operators
Wiki: Keywords
Wiki: keywords-byvalue
Wiki: keywords-const
Wiki: keywords-expression
Wiki: keywords-out
Wiki: keywords-returns
Wiki: keywords-typealias
Wiki: keywords-var
Wiki: operators-can-be-null