FIND YOUR NEXT FEW LINES

Results for “Functions & error handling”

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

156 snippets foundClear filters
TypeScriptArray traversal & selection

Pair corresponding array items by position

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

TypeScript✓ Tested
C#LINQ transformations

Pair corresponding collection elements

C#: Zip stops at the shorter sequence, so validate lengths separately if mismatches are an error.

C#✓ Tested
C++Numeric parsing & calculations

Parse a complete integer without exceptions

C++: from_chars reports both an error code and the first unconsumed character.

C++✓ Tested
Bash ScriptsFunctions & arguments

Parse a short option with getopts

Read a named option and handle invalid flags explicitly.

getopts✓ Tested
PowerShellText & data

Parse JSON into an object

Access a named field in a JSON document.

JSON✓ Tested
PowerShellFunctions & control

Pass named parameters from a hashtable

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

splatting✓ Tested
JavaEncoding & structured values

Read a big-endian integer from bytes

Java: Set a byte order explicitly when handling a binary protocol.

Java✓ 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
CFile positioning & lifecycle

Read a stream again from its beginning

C: rewind returns a seekable stream to offset zero and clears its error and EOF indicators.

C✓ Tested
PowerShellCommands & execution context

Read the kind of command being invoked

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

PowerShell✓ Tested
C++Filesystem operations

Rename a known file through filesystem

C++: filesystem::rename reports an error by exception when the operation fails.

C++✓ Tested