carpentries-incubator / workflows-nextflow

Workflow management with Nextflow and nf-core
https://carpentries-incubator.github.io/workflows-nextflow/
Other
21 stars 34 forks source link

Nextflow review @bobturneruk ep4 ${...} #126

Open ggrimes opened 5 months ago

ggrimes commented 5 months ago

Do inputs need to be wrapped in ${...} when used in a script? What is good practise?

ggrimes commented 5 months ago

The nextflow variable don't have to wrapped in braces but it is useful when concatenate variable names with other strings, as the boundaries of the variable name can become unclear wittout the use of ${..}.

In the VARIABLE SUBSTITUTIONS callout I mention this. Similar to bash scripting Nextflow uses the $ character to introduce variable substitutions. The variable name to be expanded may be enclosed in braces {variable_name}, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name. It is a good rule of thumb to always use the {} syntax because it enhances readability and clarity, ensures correct variable interpretation, and prevents potential syntax errors in complex expressions.