FIND YOUR NEXT FEW LINES

Results for “function”

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

124 snippets foundClear filters
PythonFunctions & error handling

Avoid a shared mutable default argument

Python: Create a fresh list inside the function when the optional argument is omitted.

Python✓ Tested
PythonFunctions & error handling

Capture a successful child-process result

Python: Run an argument list without a shell and check the return code.

Python✓ Tested
RustFunctions & data types

Capture a surrounding value in a closure

Capture a surrounding value in a closure in a complete Rust program using the standard library.

Rust✓ Tested
Bash ScriptsFunction scope & composition

Capture output while handling a failed command

Bash Scripts: An assignment inherits the status of its command substitution, allowing both output and status to be handled.

Bash Scripts✓ Tested
GoFunctions & types

Capture state in a closure

Capture state in a closure using a complete Go program with explicit sample inputs.

Go✓ Tested
CSSResponsive conditions & sizing

Choose the smaller of a fixed and viewport-relative size

CSS: Min selects whichever supplied length is smaller at the current viewport.

CSS✓ Tested
PythonFunctions & error handling

Collect independent asynchronous results

Python: Use asyncio.gather to await multiple coroutines while preserving input order.

Python✓ Tested
RustFunctions & data types

Construct a struct with default values

Construct a struct with default values in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Define behavior with a trait

Define behavior with a trait in a complete Rust program using the standard library.

Rust✓ Tested
GoFunctions & types

Define related integer constants

Define related integer constants using a complete Go program with explicit sample inputs.

Go✓ Tested
RustFunctions & data types

Derive comparison and debugging behavior

Derive comparison and debugging behavior in a complete Rust program using the standard library.

Rust✓ Tested
PowerShellFunctions & parameter validation

Dispatch values with wildcard patterns

PowerShell: Switch -Wildcard interprets shell-style matching patterns for each clause.

PowerShell✓ Tested