Results for “scope”
Small, practical examples. Search by task or narrow things down below.
Observe command substitution’s trailing-newline removal
Bash Scripts: Command substitution removes trailing newlines while preserving embedded ones.
Bash Scripts✓ Tested
Return a value through a named output variable
Bash Scripts: A Bash nameref can update a caller-supplied variable without command substitution.
Bash Scripts✓ Tested
Return an array through a nameref
Bash Scripts: Assign through a nameref to preserve array element boundaries.
Bash Scripts✓ Tested
Use a function’s exit status as a boolean result
Bash Scripts: Return zero for success and test the function directly in a conditional.
Bash Scripts✓ Tested
Use a recursive function for a bounded calculation
Bash Scripts: A recursive factorial demonstrates local variables and a clear base case.
Bash Scripts✓ Tested
Identify headers for individual table rows
HTML: Scope row associates the first header cell with the data cells in that row.
HTML✓ Tested
Label a data table
Use a caption and scoped headers for an HTML data table.
HTML✓ Tested
Protect a shared container with a mutex
C++: A scoped lock_guard releases the mutex when its scope ends.
C++✓ Tested
Read a repository-specific configuration value
Git: The local scope makes configuration lookup predictable for this practice repository.
Git✓ Tested
Use a small table variable
Declare rows for a short batch.
table variable✓ Tested