Results for “Functions & data types”
Small, practical examples. Search by task or narrow things down below.
Provide a fallback for a nullable value
C#: The null-coalescing operator supplies a default only when the left side is null.
C#✓ Tested
Publish updated state through a BehaviorSubject
Publish updated state through a BehaviorSubject with a standalone Angular component and explicit browser behavior.
Angular✓ Tested
Raise and catch a domain-specific exception
Python: Give a validation failure its own exception type so callers can handle it narrowly.
Python✓ Tested
Read a file length in bytes
Java: Files.size inspects metadata without loading the file into a Java string.
Java✓ Tested
Read a little-endian integer from bytes
Read a little-endian integer from bytes in a complete Rust program using the standard library.
Rust✓ Tested
Read a small INI configuration
Python: Use ConfigParser typed accessors for configuration values stored as text.
Python✓ Tested
Read a tab-separated table
Python: Select a delimiter explicitly rather than splitting lines manually.
Python✓ Tested
Read an ISO-style weekday number
TypeScript: Convert Sunday from zero to seven when using Monday-through-Sunday numbering.
TypeScript✓ Tested
Read an object’s own enumerable values
TypeScript: Object.values provides values without their corresponding keys.
TypeScript✓ Tested
Read date components in UTC
TypeScript: UTC accessors avoid differences caused by the machine’s local timezone.
TypeScript✓ Tested
Read elements from trusted XML
Python: Use ElementTree to inspect a small trusted XML document.
Python✓ Tested
Read named regex capture groups
TypeScript: Named groups make a fixed input format easier to inspect than numeric group positions.
TypeScript✓ Tested