Skip to content

Commit

Permalink
Specify that functions can return references under certain conditions (
Browse files Browse the repository at this point in the history
…aptos-labs#8644)

* Add note that functions can return references

* Mention that inline functions can return such references
  • Loading branch information
saharct authored and xbtmatt committed Jul 25, 2023
1 parent ecac0c5 commit 431abb0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions developer-docs-site/docs/move/book/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ fun zero(): u64 { 0 }

Here `: u64` indicates that the function's return type is `u64`.

:::tip
A function can return an immutable `&` or mutable `&mut` [reference](./references.md) if derived from an input reference. Keep in mind, this means that a function [cannot return a reference to global storage](./references.md#references-cannot-be-stored) unless it is an [inline function](#inline-functions).
:::

Using tuples, a function can return multiple values:

```move
Expand Down

0 comments on commit 431abb0

Please sign in to comment.