Results for “Parameter expansion”
Small, practical examples. Search by task or narrow things down below.
Keep function-local assignments separate from caller state
PowerShell: Ordinary function assignments create local variables rather than replacing the caller’s variable.
PowerShell✓ Tested
Pass a block of behavior as an argument
PowerShell: Invoke a scriptblock with the call operator and an explicit input value.
PowerShell✓ Tested
Preserve a failure after local cleanup
PowerShell: A bare throw inside catch rethrows the current exception.
PowerShell✓ Tested
Return a collection as one pipeline object
PowerShell: The unary comma prevents the returned array from being enumerated at this boundary.
PowerShell✓ Tested
Return a status separately from a calculated result
C: An output pointer lets a function return success or failure independently of its numeric result.
C✓ Tested
Run cleanup after a caught exception
PowerShell: Use finally for cleanup that must occur after either success or failure.
PowerShell✓ Tested
Build a URL query string
Python: Use urlencode to percent-encode query parameter values correctly.
Python✓ Tested
Build a URL query string from values
JavaScript: URLSearchParams handles query escaping and repeated parameter appends.
JavaScript✓ Tested
Build a URL query string from values
TypeScript: URLSearchParams handles query escaping and repeated parameter appends.
TypeScript✓ Tested
Check whether a variable exists under nounset
Bash Scripts: The plus expansion distinguishes an unset variable without reading its missing value.
Bash Scripts✓ Tested
Consume positional arguments one at a time
Bash Scripts: Check the argument count before accessing the first parameter with nounset enabled.
Bash Scripts✓ Tested
Convert a string to lowercase
Normalize a text value using Bash expansion.
lowercase✓ Tested