Results for “Hashtables & object records”
Small, practical examples. Search by task or narrow things down below.
Transform an asynchronous result
Java: Chain thenApply and join a CompletableFuture to retrieve the completed value.
Java✓ Tested
Transform an optional value
Java: Use Optional.map and orElse to transform a possibly absent result.
Java✓ Tested
Update a shared counter atomically
Java: AtomicInteger provides an indivisible increment operation for a shared counter.
Java✓ Tested
Validate a required argument
Java: Use requireNonNull with a useful message at an API boundary.
Java✓ Tested
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested
Attach configuration when registering a handler
jQuery: event.data carries the registration-time data object.
jQuery✓ Tested
Check JSONB containment
Test whether an object contains a key-value pair.
jsonb✓ Tested
Check out another branch in a second working tree
Git: A linked worktree shares repository objects while maintaining a separate checked-out branch.
Git✓ Tested
Collect repeated form field names
jQuery: serializeArray preserves multiple values as name-value records.
jQuery✓ Tested
Copy nested mutable data independently
Python: Use deepcopy when changes to nested lists must not affect the original object.
Python✓ Tested
Count days between calendar dates
Python: Subtract date objects to get an exact calendar-day difference.
Python✓ Tested
Count words using a Map
Update a keyed counter without losing its value type.
Map✓ Tested