Results for “Ownership & optional values”
Small, practical examples. Search by task or narrow things down below.
Turn known group values into columns
Postgres: Conditional aggregation gives a portable pivot when the category set is known.
Postgres✓ Tested
Turn known group values into columns
SQLite: Conditional aggregation gives a portable pivot when the category set is known.
SQLite✓ Tested
Understand default zero values
Understand default zero values using a complete Go program with explicit sample inputs.
Go✓ Tested
Use an optional fallback
Use Optional.orElse to provide a default for a missing Java value.
Java✓ Tested
Wait for several deferred values
jQuery: when resolves only after every supplied deferred has resolved.
jQuery✓ Tested
Yield values on demand
Python: Use a generator to produce a sequence without storing all intermediate values.
Python✓ Tested
Allocate an independent copy of a C string
C: Include one extra byte for the terminating null character.
C✓ Tested
Allocate and free a typed array
C: Use sizeof on the pointed-to type and check allocation success before writing.
C✓ Tested
Allocate and initialize a structure
C: Use a compound literal assignment to initialize all ordinary structure fields.
C✓ Tested
Assemble a big-endian 16-bit value
Arduino / C: Cast to an unsigned 16-bit type before shifting the high byte.
Arduino / C✓ Tested
Assign a bit from a Boolean state
Arduino / C: bitWrite accepts a bit position and a zero or nonzero value.
Arduino / C✓ Tested
Borrow local data in a scoped thread
Borrow local data in a scoped thread in a complete Rust program using the standard library.
Rust✓ Tested