Results for “Types & reliable control flow”
Small, practical examples. Search by task or narrow things down below.
Decode a percent-encoded URL component
TypeScript: decodeURIComponent reverses percent encoding and throws for malformed sequences.
TypeScript✓ Tested
Define behavior with a trait
Define behavior with a trait in a complete Rust program using the standard library.
Rust✓ Tested
Define related integer constants
Define related integer constants using a complete Go program with explicit sample inputs.
Go✓ Tested
Delegate iteration to another iterable
TypeScript: yield-star forwards items from another iterable while retaining generator composition.
TypeScript✓ Tested
Derive comparison and debugging behavior
Derive comparison and debugging behavior in a complete Rust program using the standard library.
Rust✓ Tested
Detect an invalid Date object
TypeScript: An invalid Date has a NaN time value.
TypeScript✓ Tested
Detect NaN without converting the input
TypeScript: Number.isNaN tests the special numeric value instead of applying string-to-number conversion.
TypeScript✓ Tested
Display a label in uppercase without changing its text
CSS: Text-transform changes visual casing while preserving the DOM’s source text.
CSS✓ Tested
Display a number with a fixed decimal width
TypeScript: toFixed returns a formatted string rather than a numeric value.
TypeScript✓ Tested
Distinguish an own property from an inherited one
TypeScript: Object.hasOwn avoids depending on an object’s possibly shadowed hasOwnProperty method.
TypeScript✓ Tested
Divide using a fractional number
TypeScript: Use a floating-point operand to preserve the fractional part of a division.
TypeScript✓ Tested
Drop the fractional part toward zero
TypeScript: Math.trunc differs from floor for negative inputs.
TypeScript✓ Tested