FIND YOUR NEXT FEW LINES

Results for “Functions & error handling”

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

156 snippets foundClear filters
Bash ScriptsFunctions & arguments

Return text from a shell function

Capture a function’s output with command substitution.

function✓ Tested
TypeScriptTypes & functions

Return the first item with a generic function

Preserve the element type while allowing empty arrays.

generics✓ Tested
SQLWindow analytics

Select the top row in each group with a tie-breaker

SQL: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.

SQL✓ Tested
SQL ServerWindow analytics

Select the top row in each group with a tie-breaker

SQL Server: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.

SQL Server✓ Tested
PostgresWindow analytics

Select the top row in each group with a tie-breaker

Postgres: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.

Postgres✓ Tested
SQLiteWindow analytics

Select the top row in each group with a tie-breaker

SQLite: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.

SQLite✓ Tested
PowerShellFunctions & control

Transform each item in a collection

Build a result array with a foreach expression.

foreach✓ Tested
TypeScriptTypes & functions

Type a function’s inputs and output

Catch mismatched arguments during compilation.

function✓ Tested
TypeScriptSafe data handling

Update an object with a readonly input

Create a changed copy while retaining the original.

readonly✓ Tested
CNumeric parsing & arithmetic

Validate a complete floating-point input

C: strtod exposes both the stopping position and range errors; reject nonfinite results when required.

C✓ 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
TypeScriptSafe data handling

Validate an unknown value with a type guard

Check a field before treating unknown data as a typed object.

unknown✓ Tested