Results for “save file”
Small, practical examples. Search by task or narrow things down below.
Group records by a field
Python: Accumulate related values with defaultdict without checking whether each group exists.
Python✓ Tested
Group records into map entries
JavaScript: Initialize an array for a missing Map key before appending its values.
JavaScript✓ Tested
Group records into map entries
TypeScript: Initialize an array for a missing Map key before appending its values.
TypeScript✓ Tested
Group related values in nested structures
C: Nested members model a record that owns another simple record.
C✓ Tested
Group strings by their length
Java: Choose a TreeMap supplier when group keys must have deterministic order.
Java✓ 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
Handle a failed string-to-integer conversion
C++: stoi throws invalid_argument when no conversion can be performed.
C++✓ Tested
Handle a form without navigating away
jQuery: Learn how to handle a form without navigating away in a complete browser example.
jQuery✓ Tested
Handle a nonzero background-job exit
Bash Scripts: Wait reports a child’s exit code; put it in a conditional when failure is expected.
Bash Scripts✓ Tested
Handle a request timeout
jQuery: The timeout option bounds how long the client waits.
jQuery✓ Tested
Handle a result with a discriminated union
Separate success data from an error message.
discriminated union✓ Tested
Handle an expected child-process failure
Python: Catch CalledProcessError when check=True reports a nonzero exit status.
Python✓ Tested