Results for “optional argument”
Small, practical examples. Search by task or narrow things down below.
Capture a successful child-process result
Python: Run an argument list without a shell and check the return code.
Python✓ Tested
Create a native disclosure
Use details and summary to show optional HTML content without JavaScript.
HTML✓ Tested
Drop capabilities for a Compose service
Docker / Compose: cap_drop ALL removes optional Linux capabilities.
Docker / Compose✓ Tested
Enforce a numeric range at a function boundary
PowerShell: ValidateRange performs argument validation before work begins.
PowerShell✓ Tested
Extract a substring with an explicit count
C++: The second substr argument is a length rather than an ending index.
C++✓ Tested
Find an element’s position among siblings
jQuery: index without arguments reports a zero-based sibling position.
jQuery✓ Tested
Format a numeric label with leading zeroes
Bash Scripts: Use a constant printf format string and supply values as separate arguments.
Bash Scripts✓ Tested
Generate a sequence of numbers
Create rows without a stored table.
generate_series✓ Tested
Handle a failed string-to-integer conversion
C++: stoi throws invalid_argument when no conversion can be performed.
C++✓ Tested
Handle an expected command failure
Branch on a command’s exit code without aborting the script.
exit status✓ Tested
Look up values in an associative array
Use named keys for a small in-memory configuration table.
dictionary✓ Tested
Loop over an array safely
Preserve spaces in array elements while iterating.
array✓ Tested