FIND YOUR NEXT FEW LINES

Results for “Functions & types”

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

202 snippets foundClear filters
Bash ScriptsFunctions & arguments

Parse a short option with getopts

Read a named option and handle invalid flags explicitly.

getopts✓ Tested
PowerShellFunctions & control

Pass named parameters from a hashtable

Keep a command’s options together in a reusable object.

splatting✓ Tested
Arduino / CEEPROM & program memory

Read a byte lookup table from flash

Arduino / C: PROGMEM tables require the AVR program-memory access functions.

Arduino / C✓ Tested
TypeScriptSafe data handling

Read a nested optional value

Avoid dereferencing a missing nested object.

optional chaining✓ Tested
TypeScriptUtilities & async

Read a property with keyof

Keep the key and returned value tied to an object type.

keyof✓ Tested
PowerShellCommands & execution context

Read the kind of command being invoked

PowerShell: CommandType distinguishes cmdlets from functions, aliases, and external applications.

PowerShell✓ Tested
TypeScriptCollections & records

Remove duplicate values with a Set

Keep the first occurrence order while deduplicating.

Set✓ Tested
Bash ScriptsFunctions & arguments

Return text from a shell function

Capture a function’s output with command substitution.

function✓ Tested
TypeScriptUtilities & async

Return typed data from an async function

Await a Promise and handle failures explicitly.

async✓ Tested
TypeScriptSafe data handling

Safely read a caught error

Check the error type before accessing its message.

unknown✓ Tested
TypeScriptUtilities & async

Select fields with the Pick utility type

Expose a smaller view of a larger object type.

Pick✓ 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