FIND YOUR NEXT FEW LINES

Results for “save”

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

1671 snippets foundClear filters
JavaQueues & collection operations

Use a deque as a stack

Java: Use push and pop for last-in, first-out behavior.

Java✓ Tested
PowerShellHashtables & object records

Use a fallback for a missing hashtable entry

PowerShell: Test the key explicitly so legitimate false or zero values are preserved.

PowerShell✓ Tested
Bash ScriptsGetting Started

Use a fallback for an unset variable

Bash Scripts: Use a fallback for an unset variable with a small standalone Bash program.

Bash Scripts✓ Tested
C++Containers & compound values

Use a fixed-size container with bounds checking

C++: std::array retains its element count and supports checked access through at.

C++✓ Tested
Bash ScriptsFunction scope & composition

Use a function’s exit status as a boolean result

Bash Scripts: Return zero for success and test the function directly in a conditional.

Bash Scripts✓ Tested
C++Containers & compound values

Use a hash map for direct key lookup

C++: unordered_map provides key lookup without promising iteration order.

C++✓ Tested
C++Containers & compound values

Use a last-in first-out stack

C++: Read top before pop because pop does not return the removed value.

C++✓ Tested
PowerShellStrings & literal text

Use a literal value in a regular expression

PowerShell: Regex.Escape prevents a literal dot or other metacharacter from changing the match.

PowerShell✓ Tested
RustNumbers & durations

Use a nonnegative remainder for cyclic indexing

Use a nonnegative remainder for cyclic indexing in a complete Rust program using the standard library.

Rust✓ Tested
Bash ScriptsFunction scope & composition

Use a recursive function for a bounded calculation

Bash Scripts: A recursive factorial demonstrates local variables and a clear base case.

Bash Scripts✓ Tested
Bash ScriptsParameter expansion

Use an alternate value only when a variable is nonempty

Bash Scripts: The colon-plus expansion returns its word only when the parameter has a nonempty value.

Bash Scripts✓ Tested
RustFunctions & data types

Use an associated constructor

Use an associated constructor in a complete Rust program using the standard library.

Rust✓ Tested