Results for “Errors & 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
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
Build a minimum-priority queue
C++: Supply greater as the comparator because priority_queue defaults to the largest value first.
C++✓ Tested
Calculate a CRC-8 over a byte sequence
Arduino / C: This implementation uses polynomial 0x07, initial zero, and no reflection.
Arduino / C✓ Tested
Calculate a SHA-256 content digest
Java: Hash UTF-8 bytes and format the result as lowercase hexadecimal.
Java✓ Tested
Calculate a simple packet XOR checksum
Arduino / C: XOR all payload bytes to produce a basic error-detection byte.
Arduino / C✓ Tested