Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/docs/noir/concepts/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ is pre-pended with a colon and the parameter type. Multiple parameters are separ
fn foo(x : Field, y : Field){}
```

You can use an underscore `_` as a parameter name when you don't need to use the parameter in the function body. This is useful when you need to satisfy a function signature but don't need to use all the parameters:

```rust
fn foo(_ : Field, y : Field) {
// Only using y parameter
}
```

Alternatively, you can prefix a parameter name with an underscore (e.g. `_x`), which also indicates that the parameter is unused. This approach is often preferred as it preserves the parameter name for documentation purposes:

```rust
fn foo(_x : Field, y : Field) -> Field {
// Only using y parameter
y
}
```

The return type of a function can be stated by using the `->` arrow notation. The function below
states that the foo function must return a `Field`. If the function returns no value, then the arrow
is omitted.
Expand Down
Loading