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
GoFunctions & types

Write a generic slice helper

Write a generic slice helper using a complete Go program with explicit sample inputs.

Go✓ Tested
CSSFlexbox alignment

Allow a long flex child to shrink inside its container

CSS: Min-width zero removes the default content-size floor so local overflow handling can take effect.

CSS✓ Tested
HTMLInput constraints

Allow several selected options

HTML: A multiple select exposes each selected option as a value with the same control name.

HTML✓ Tested
Arduino / CData & storage

Average a fixed set of readings

Accumulate sample values without overflowing a 16-bit total.

array✓ Tested
TypeScriptUtilities & async

Await several independent results

Preserve input order while awaiting multiple promises.

Promise.all✓ Tested
Arduino / CTiming & control

Blink without blocking the loop

Use elapsed millis time instead of delay for a repeating action.

millis✓ Tested
CSmall algorithms & bit operations

Calculate a least common multiple using a GCD

C: Divide before multiplying to reduce the risk of intermediate overflow.

C✓ Tested
C++Numeric parsing & calculations

Calculate a two-dimensional vector length

C++: hypot avoids unnecessary intermediate overflow in the sum of squares.

C++✓ Tested
JavaPrecise numeric calculations

Calculate beyond the long integer range

Java: Use BigInteger when a fixed-width primitive type would overflow.

Java✓ Tested
C++Text validation & parsing

Check a literal suffix in C++17

C++: Check lengths before subtracting to avoid an unsigned underflow.

C++✓ Tested
Docker / ComposeCompose service options

Choose a service’s internal hostname

Docker / Compose: hostname controls the name reported inside the container.

Docker / Compose✓ Tested
PowerShellFunctions & control

Choose an action with switch

Map a small command value to a result.

switch✓ Tested