FIND YOUR NEXT FEW LINES

Results for “Types & reliable control flow”

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

308 snippets foundClear filters
TypeScriptTypes & functions

Return the first item with a generic function

Preserve the element type while allowing empty arrays.

generics✓ Tested
TypeScriptUtilities & async

Return typed data from an async function

Await a Promise and handle failures explicitly.

async✓ Tested
TypeScriptSafe data handling

Safely read a caught error

Check the error type before accessing its message.

unknown✓ Tested
TypeScriptUtilities & async

Select fields with the Pick utility type

Expose a smaller view of a larger object type.

Pick✓ Tested
CSSGrid placement

Set explicit grid row heights

CSS: Grid-template-rows controls each declared row’s block-axis track size.

CSS✓ Tested
CArray transformations

Sort an integer array with qsort

C: The comparator uses relational comparisons to avoid subtraction overflow.

C✓ Tested
Linux CommandsDates & process utilities

Start a command with a minimal environment

Linux Commands: Use env -i with an explicit PATH for a controlled child environment.

Linux Commands✓ Tested
CSSInteraction selectors

Style a card based on a selected descendant

CSS: Has matches the parent when its relative selector finds a checked control inside it.

CSS✓ Tested
CSSInteraction selectors

Style content associated with a checked option

CSS: The adjacent-sibling selector connects a checked control with its following label text.

CSS✓ Tested
HTMLForm behavior

Submit a readonly value while preventing edits

HTML: Readonly controls remain in form data, unlike disabled controls.

HTML✓ Tested
TypeScriptCollections & records

Sum typed values with reduce

Accumulate numeric array elements.

reduce✓ Tested
CNumbers & memory

Swap two integers

Use a temporary value to swap C integers without arithmetic overflow.

C✓ Tested