FIND YOUR NEXT FEW LINES

Results for “when”

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

230 snippets foundClear filters
C++Tasks & synchronization

Protect a shared container with a mutex

C++: A scoped lock_guard releases the mutex when its scope ends.

C++✓ Tested
C#Types & reliable control flow

Provide a fallback for a nullable value

C#: The null-coalescing operator supplies a default only when the left side is null.

C#✓ Tested
CSSResponsive conditions & sizing

Provide a fallback for an unset custom property

CSS: The second var argument supplies a value when the custom property is unavailable.

CSS✓ Tested
GitRemotes & collaboration

Pull without creating a merge commit

Update a branch only when its upstream can be fast-forwarded.

pull✓ Tested
C#JSON & binary formats

Read a big-endian binary integer

C#: Use BinaryPrimitives when the protocol byte order differs from or must not depend on the host.

C#✓ Tested
JavaEncoding & structured values

Read a big-endian integer from bytes

Java: Set a byte order explicitly when handling a binary protocol.

Java✓ Tested
Bash ScriptsLoops & decisions

Read a file without losing its last line

Handle spaces, backslashes, and a final line without a newline.

read lines✓ Tested
JavaCollections

Read a map with a default

Return a fallback when a Java map does not contain a key.

Java✓ Tested
JavaScriptUTC date operations

Read an ISO-style weekday number

JavaScript: Convert Sunday from zero to seven when using Monday-through-Sunday numbering.

JavaScript✓ Tested
TypeScriptUTC date operations

Read an ISO-style weekday number

TypeScript: Convert Sunday from zero to seven when using Monday-through-Sunday numbering.

TypeScript✓ Tested
Bash ScriptsArray operations

Read an optional associative-array entry

Bash Scripts: Use a fallback expansion when a map key may not be present under nounset.

Bash Scripts✓ Tested
C#JSON & binary formats

Read an optional JSON property safely

C#: Use TryGetProperty instead of throwing when an optional property is absent.

C#✓ Tested