Skip to main content

References

The video for “References” is in the works!

References allow functions to modify variables directly without copying.

Reference Parameters

Declare a reference parameter with &, pass one with &, and read or write through it with *:

Try it yourself
Loading...

Swap Function

Try it yourself
Loading...

When to Use References

References are useful when you need to modify the original value, avoid copying large data, or return multiple values.

Try it yourself
Loading...

Previous: Interfaces | Next: Modules