FIND YOUR NEXT FEW LINES

Results for “guard”

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

9 snippets foundClear filters
TypeScriptSafe data handling

Validate an unknown value with a type guard

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

unknown✓ Tested
ReactEffects & lifecycle

Skip synchronization when a feature is disabled

Skip synchronization when a feature is disabled with a small React component and explicit browser behavior.

React✓ 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
SQLReporting & grouped calculations

Compute an integer weighted average

SQL: Multiply before summing and guard a zero total weight with NULLIF.

SQL✓ Tested
SQL ServerReporting & grouped calculations

Compute an integer weighted average

SQL Server: Multiply before summing and guard a zero total weight with NULLIF.

SQL Server✓ Tested
PostgresReporting & grouped calculations

Compute an integer weighted average

Postgres: Multiply before summing and guard a zero total weight with NULLIF.

Postgres✓ Tested
SQLiteReporting & grouped calculations

Compute an integer weighted average

SQLite: Multiply before summing and guard a zero total weight with NULLIF.

SQLite✓ Tested
SQL ServerTransactions & tables

Generate a bounded sequence recursively

Use a recursive CTE with a recursion limit.

recursive CTE✓ Tested
C++Tasks & synchronization

Protect a shared container with a mutex

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

C++✓ Tested