Results for “Functions & types”
Small, practical examples. Search by task or narrow things down below.
Parse a short option with getopts
Read a named option and handle invalid flags explicitly.
getopts✓ Tested
Pass named parameters from a hashtable
Keep a command’s options together in a reusable object.
splatting✓ Tested
Read a byte lookup table from flash
Arduino / C: PROGMEM tables require the AVR program-memory access functions.
Arduino / C✓ Tested
Read a nested optional value
Avoid dereferencing a missing nested object.
optional chaining✓ Tested
Read a property with keyof
Keep the key and returned value tied to an object type.
keyof✓ Tested
Read the kind of command being invoked
PowerShell: CommandType distinguishes cmdlets from functions, aliases, and external applications.
PowerShell✓ Tested
Remove duplicate values with a Set
Keep the first occurrence order while deduplicating.
Set✓ Tested
Return text from a shell function
Capture a function’s output with command substitution.
function✓ Tested
Return typed data from an async function
Await a Promise and handle failures explicitly.
async✓ Tested
Safely read a caught error
Check the error type before accessing its message.
unknown✓ Tested
Select fields with the Pick utility type
Expose a smaller view of a larger object type.
Pick✓ Tested
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