Skip to content

Commit

Permalink
Add note about implicit closure parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Oct 23, 2024
1 parent 04a311d commit 63633d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/reference/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -954,4 +954,4 @@ The following legacy features were excluded from this page because they are depr

- The `addParams` and `params` clauses of include declarations. See {ref}`module-params` for more information.
- The `when:` section of a process definition. See {ref}`process-when` for more information.
- The implicit `it` closure parameter
- The implicit `it` closure parameter. See {ref}`script-closure` for more information.
10 changes: 10 additions & 0 deletions docs/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ def result = counts.values().inject { sum, v -> sum + v }

This way, the closure is fully "self-contained" because it doesn't access or mutate any variables outside of its scope.

:::{note}
When a closure takes a single parameter, the parameter can be omitted, in which case the implicit `it` parameter will be used:

```groovy
[1, 2, 3].each { println it }
```

However, this practice is deprecated and will not be supported in the future.
:::

## Script definitions

So far, we have been focusing on the basic building blocks of Nextflow code, like variables, lists, strings, and closures.
Expand Down

0 comments on commit 63633d1

Please sign in to comment.