FIND YOUR NEXT FEW LINES

Results for “Functions & types”

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

202 snippets foundClear filters
TypeScriptNumbers & numeric validation

Validate a finite numeric value without coercion

TypeScript: Number.isFinite rejects numeric strings as well as NaN and infinity.

TypeScript✓ Tested
TypeScriptRegular expressions & URL encoding

Validate a whole ASCII identifier

TypeScript: Use an anchored expression without the multiline flag and reject a trailing line break explicitly.

TypeScript✓ Tested
C#Types & reliable control flow

Validate an argument at a method boundary

C#: ThrowIfNegative gives callers an explicit argument error for an invalid range.

C#✓ Tested
TypeScriptGetting Started

Visit every item in a collection

TypeScript: Print each element in the collection’s original order.

TypeScript✓ Tested
C#Types & reliable control flow

Write a generic first-or-fallback helper

C#: Constrain a generic helper through its input shape and return an explicit caller-supplied fallback.

C#✓ Tested
PythonFunctions & error handling

Yield values on demand

Python: Use a generator to produce a sequence without storing all intermediate values.

Python✓ Tested
TypeScriptUtilities & async

Await several independent results

Preserve input order while awaiting multiple promises.

Promise.all✓ Tested
PowerShellFunctions & control

Choose an action with switch

Map a small command value to a result.

switch✓ Tested
PowerShellDates & numeric validation

Compute beyond the fixed-width integer range

PowerShell: BigInteger keeps an exact result when ordinary integer types are too small.

PowerShell✓ Tested
CBinary formats & structured parsing

Convert ASCII text to lowercase safely

C: Cast to unsigned char before calling ctype functions on a possibly signed char.

C✓ Tested
Arduino / CSerial protocols

Convert received ASCII letters to uppercase

Arduino / C: ctype functions should receive an unsigned character value.

Arduino / C✓ Tested
TypeScriptCollections & records

Count words using a Map

Update a keyed counter without losing its value type.

Map✓ Tested