Results for “assign”
Small, practical examples. Search by task or narrow things down below.
Copy an array independently
Bash Scripts: A new array assignment copies element values rather than creating a shared reference.
Bash Scripts✓ Tested
Count the elements in an array
Bash Scripts: The array length form counts assigned elements, not characters in the first value.
Bash Scripts✓ Tested
Divide an ordered result into numbered buckets
SQL: NTILE distributes rows across buckets; include a unique tie-breaker for deterministic assignment.
SQL✓ Tested
Divide an ordered result into numbered buckets
SQL Server: NTILE distributes rows across buckets; include a unique tie-breaker for deterministic assignment.
SQL Server✓ Tested
Divide an ordered result into numbered buckets
Postgres: NTILE distributes rows across buckets; include a unique tie-breaker for deterministic assignment.
Postgres✓ Tested
Divide an ordered result into numbered buckets
SQLite: NTILE distributes rows across buckets; include a unique tie-breaker for deterministic assignment.
SQLite✓ Tested
Give an LED pin a constant name
Arduino / C: Use const to name the built-in LED pin and reuse it in output instructions.
Arduino / C✓ Tested
Grow an allocation without losing it on failure
C: Assign realloc to a temporary pointer so the original allocation remains available if growth fails.
C✓ Tested
Increment a counter without an unexpected errexit
Bash Scripts: An assignment avoids the zero-result exit status of a standalone arithmetic post-increment.
Bash Scripts✓ Tested
Initialize structure fields by name
C: Designated initializers make field assignments independent of their declaration order.
C✓ Tested
Isolate variable changes in a subshell
Bash Scripts: Parentheses create a subshell whose variable assignments do not change the parent.
Bash Scripts✓ Tested
Keep a function variable local
Bash Scripts: Local prevents an ordinary function assignment from replacing a caller variable.
Bash Scripts✓ Tested