Using Nasal functions: Difference between revisions

Jump to navigation Jump to search
m
Line 168: Line 168:
As an alternative to the comma-separated list of ''positional'' function arguments, you can specify a hash literal in place of ordered function arguments, and it will become the local variable namespace for the called function, with variables named according to the hash indexes and with values according to the hash values.  This makes functions with many arguments more readable.  
As an alternative to the comma-separated list of ''positional'' function arguments, you can specify a hash literal in place of ordered function arguments, and it will become the local variable namespace for the called function, with variables named according to the hash indexes and with values according to the hash values.  This makes functions with many arguments more readable.  


And it also makes it possible to call function's without having to take care of the right order of passing arguments.
And it also makes it possible to call function's without having to take care of the right order of passing arguments, which comes in especially handy once you have to work with code that you haven't touched in a while. Basically, it's a really good idea to always make use of this whenever a function is non-trivial, in that it may take more than just 2 straightforward arguments.


Examples:
Examples:

Navigation menu