Results for “Type & reading flow”
Small, practical examples. Search by task or narrow things down below.
Resolve a relative URL against a base
TypeScript: A trailing slash makes the final base path component a directory.
TypeScript✓ Tested
Return a value from a switch expression
Java: Use an exhaustive switch expression with a fallback for other input values.
Java✓ Tested
Reverse a copy while preserving the original
TypeScript: Copy before reverse because reverse mutates the array it receives.
TypeScript✓ Tested
Run a task on an executor and close it
Java: Java 21 ExecutorService supports try-with-resources to shut down after submitted work.
Java✓ Tested
Run cleanup after a handled exception
Java: A finally block executes whether the protected operation succeeds or fails.
Java✓ Tested
Run cleanup after a promise settles
TypeScript: finally runs after success or failure and normally preserves the original outcome.
TypeScript✓ Tested
Run dependent async steps in order
TypeScript: Await one result before using it as the input of the next calculation.
TypeScript✓ Tested
Run your first program
TypeScript: Start with a complete program that prints one line. Follow the run instructions below.
TypeScript✓ Tested
Scroll wide code locally
Keep long code inside a horizontally scrollable CSS container.
CSS✓ Tested
Send a value through a channel
Send a value through a channel in a complete Rust program using the standard library.
Rust✓ Tested
Separate a first item from the remaining items
TypeScript: Array destructuring and a rest element produce named pieces of a sequence.
TypeScript✓ Tested
Set and inspect a bit flag
Store several boolean states in one byte.
bitSet✓ Tested