FIND YOUR NEXT FEW LINES

Results for “library”

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

653 snippets foundClear filters
PythonGetting Started

Name a value that stays fixed

Python: Use a constant declaration or the language’s constant naming convention for a fixed limit.

Python✓ Tested
JavaGetting Started

Name a value that stays fixed

Java: Use a constant declaration or the language’s constant naming convention for a fixed limit.

Java✓ Tested
JavaRecords & reliable control flow

Narrow an object with a pattern variable

Java: Pattern matching avoids a separate cast after a successful instanceof check.

Java✓ Tested
PythonText validation & encoding

Normalize equivalent Unicode strings

Python: Normalize to NFC before comparing canonically equivalent text.

Python✓ Tested
JavaFile operations & binary data

Normalize relative path components

Java: Path.normalize removes redundant dot components without accessing the filesystem.

Java✓ Tested
PythonIteration & sequences

Number items while iterating

Python: Use enumerate to attach a one-based position without maintaining a separate counter.

Python✓ Tested
RustIterators & transformations

Number items while iterating

Number items while iterating in a complete Rust program using the standard library.

Rust✓ Tested
jQueryDeferred work & queues

Observe completion of queued work

jQuery: The queue promise resolves when the selected elements’ queue is empty.

jQuery✓ Tested
GoConcurrency & cancellation

Observe context cancellation

Observe context cancellation using a complete Go program with explicit sample inputs.

Go✓ Tested
RustTesting & reusable patterns

Own a heap-allocated value with Box

Own a heap-allocated value with Box in a complete Rust program using the standard library.

Rust✓ Tested
PythonStructured data & serialization

Pack and unpack a network-order integer

Python: Use an explicit byte order so the binary format is independent of the host architecture.

Python✓ Tested
PythonIteration & sequences

Pair corresponding list items

Python: Zip two equally sized sequences into pairs; strict mode rejects mismatched lengths on Python 3.10 or later.

Python✓ Tested