FIND YOUR NEXT FEW LINES

Results for “Sorting & joining records”

Small, practical examples. Search by task or narrow things down below.

84 snippets foundClear filters
PowerShellHashtables & object records

Find differences between two collections

PowerShell: Compare-Object marks reference-only values with a left arrow and difference-only values with a right arrow.

PowerShell✓ Tested
PowerShellHashtables & object records

Merge configuration maps with override precedence

PowerShell: Copy defaults before applying override keys so the original remains unchanged.

PowerShell✓ Tested
JavaRecords & reliable control flow

Narrow an object with a pattern variable

Java: Pattern matching avoids a separate cast after a successful instanceof check.

Java✓ Tested
PowerShellHashtables & object records

Preserve key insertion order

PowerShell: An ordered dictionary enumerates keys in the order they were inserted.

PowerShell✓ Tested
PowerShellHashtables & object records

Remove an optional hashtable entry

PowerShell: Remove changes the map in place without changing unrelated entries.

PowerShell✓ Tested
JavaRecords & reliable control flow

Represent a finite set of states

Java: Use an enum to prevent arbitrary strings from representing application states.

Java✓ Tested
JavaRecords & reliable control flow

Return a value from a switch expression

Java: Use an exhaustive switch expression with a fallback for other input values.

Java✓ Tested
JavaRecords & reliable control flow

Run a task on an executor and close it

Java: Java 21 ExecutorService supports try-with-resources to shut down after submitted work.

Java✓ Tested
JavaRecords & reliable control flow

Run cleanup after a handled exception

Java: A finally block executes whether the protected operation succeeds or fails.

Java✓ Tested
JavaRecords & reliable control flow

Transform an asynchronous result

Java: Chain thenApply and join a CompletableFuture to retrieve the completed value.

Java✓ Tested
JavaRecords & reliable control flow

Transform an optional value

Java: Use Optional.map and orElse to transform a possibly absent result.

Java✓ Tested
JavaRecords & reliable control flow

Update a shared counter atomically

Java: AtomicInteger provides an indivisible increment operation for a shared counter.

Java✓ Tested