FIND YOUR NEXT FEW LINES

Results for “Functions & types”

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

202 snippets foundClear filters
TypeScriptArray restructuring

Keep both matching and rejected values

TypeScript: Use two explicit outputs when a caller needs both sides of a classification.

TypeScript✓ Tested
PowerShellFunctions & parameter validation

Keep function-local assignments separate from caller state

PowerShell: Ordinary function assignments create local variables rather than replacing the caller’s variable.

PowerShell✓ Tested
TypeScriptObject behavior & collections

List an object’s own enumerable keys

TypeScript: Object.keys omits inherited and non-enumerable properties.

TypeScript✓ Tested
TypeScriptArray restructuring

Map items to multiple output values

TypeScript: flatMap combines mapping and a one-level flattening operation.

TypeScript✓ Tested
TypeScriptGetting Started

Measure a short text value

TypeScript: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.

TypeScript✓ Tested
TypeScriptGetting Started

Name a value that stays fixed

TypeScript: Use a constant declaration or the language’s constant naming convention for a fixed limit.

TypeScript✓ Tested
C#Types & reliable control flow

Narrow an object using a type pattern

C#: A successful is pattern introduces a strongly typed local variable.

C#✓ Tested
TypeScriptText handling & Unicode

Normalize identifier case consistently

TypeScript: Use toLowerCase for a simple case-insensitive ASCII identifier lookup.

TypeScript✓ Tested
TypeScriptArray traversal & selection

Pair corresponding array items by position

TypeScript: Validate equal lengths before zipping when missing counterparts would be an error.

TypeScript✓ Tested
PythonFunctions & error handling

Parse a typed command-line option

Python: Use argparse to validate and convert an integer option.

Python✓ Tested
C#Types & reliable control flow

Parse an enum name without throwing

C#: Combine TryParse and IsDefined when only named declared values should be accepted.

C#✓ Tested
PowerShellFunctions & parameter validation

Pass a block of behavior as an argument

PowerShell: Invoke a scriptblock with the call operator and an explicit input value.

PowerShell✓ Tested