FIND YOUR NEXT FEW LINES

Results for “Errors & optional values”

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

354 snippets foundClear filters
CSmall algorithms & bit operations

Generate a bounded Fibonacci sequence

C: Keep only the two previous values instead of using exponential recursive calls.

C✓ Tested
PythonMappings & sets

Group records by a field

Python: Accumulate related values with defaultdict without checking whether each group exists.

Python✓ Tested
JavaScriptObject behavior & collections

Group records into map entries

JavaScript: Initialize an array for a missing Map key before appending its values.

JavaScript✓ Tested
TypeScriptObject behavior & collections

Group records into map entries

TypeScript: Initialize an array for a missing Map key before appending its values.

TypeScript✓ Tested
PowerShellFunctions & control

Handle a terminating error

Catch conversion failures and produce a clear fallback.

try catch✓ Tested
PythonStructured data & serialization

Handle malformed JSON input

Python: Catch JSONDecodeError without hiding unrelated programming errors.

Python✓ Tested
PythonGetting Started

Handle three possible outcomes

Python: Check high, normal and low values with an ordered conditional chain.

Python✓ Tested
C#Getting Started

Handle three possible outcomes

C#: Check high, normal and low values with an ordered conditional chain.

C#✓ Tested
JavaGetting Started

Handle three possible outcomes

Java: Check high, normal and low values with an ordered conditional chain.

Java✓ Tested
JavaScriptGetting Started

Handle three possible outcomes

JavaScript: Check high, normal and low values with an ordered conditional chain.

JavaScript✓ Tested
TypeScriptGetting Started

Handle three possible outcomes

TypeScript: Check high, normal and low values with an ordered conditional chain.

TypeScript✓ Tested
C++Getting Started

Handle three possible outcomes

C++: Check high, normal and low values with an ordered conditional chain.

C++✓ Tested