FIND YOUR NEXT FEW LINES

Results for “type guard”

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

225 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
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
RustFunctions & data types

Accept different types with a generic function

Accept different types with a generic function in a complete Rust program using the standard library.

Rust✓ Tested
PowerShellFunctions & parameter validation

Accept one typed value at a time from a pipeline

PowerShell: An advanced function uses process to handle each pipeline item.

PowerShell✓ Tested
HTMLGetting Started

Add a button with an explicit type

HTML: Learn how to add a button with an explicit type in a complete browser example.

HTML✓ Tested
CDynamic memory & ownership

Allocate and free a typed array

C: Use sizeof on the pointed-to type and check allocation success before writing.

C✓ Tested
AngularReactive forms

Bind a typed nonnullable FormControl

Bind a typed nonnullable FormControl with a standalone Angular component and explicit browser behavior.

Angular✓ Tested
RustGetting Started

Call a typed function

Call a typed function in a complete Rust program using the standard library.

Rust✓ Tested
RustGetting Started

Declare a typed constant

Declare a typed constant in a complete Rust program using the standard library.

Rust✓ Tested
GitTags & repository configuration

Declare LF normalization for a file type

Git: A gitattributes rule records text normalization expectations for matching paths.

Git✓ Tested
GoJSON & encoding

Decode JSON into a typed struct

Decode JSON into a typed struct using a complete Go program with explicit sample inputs.

Go✓ Tested
PowerShellFunctions & control

Define a function with a typed parameter

Accept a name and return a greeting.

function✓ Tested