FIND YOUR NEXT FEW LINES

Results for “Record”

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

111 snippets foundClear filters
PowerShellHashtables & object records

Preserve key insertion order

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

PowerShell✓ Tested
Linux CommandsSorting & joining records

Print only duplicate values

Linux Commands: Use uniq -d after sorting to report each repeated value once.

Linux Commands✓ 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
Linux CommandsSorting & joining records

Sort lines by numeric value

Linux Commands: Use sort -n so 10 sorts after 2 instead of before it.

Linux Commands✓ Tested
Linux CommandsSorting & joining records

Sort values in descending order

Linux Commands: Combine numeric sorting with reverse order.

Linux Commands✓ Tested
Linux CommandsSorting & joining records

Sort version-like labels naturally

Linux Commands: Use GNU version sort to compare embedded digit runs numerically.

Linux Commands✓ 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