Results for “Object behavior & collections”
Small, practical examples. Search by task or narrow things down below.
Create an object with named properties
PowerShell: Create an object with named properties using PowerShell 7.
PowerShell✓ Tested
Define behavior with a trait
Define behavior with a trait in a complete Rust program using the standard library.
Rust✓ Tested
Derive comparison and debugging behavior
Derive comparison and debugging behavior in a complete Rust program using the standard library.
Rust✓ Tested
Describe an object with an interface
Require named fields on a reusable object shape.
interface✓ Tested
Deserialize a JSON object into a dictionary
C#: Specify the value type expected from a known JSON shape.
C#✓ Tested
Detect an invalid Date object
JavaScript: An invalid Date has a NaN time value.
JavaScript✓ Tested
Detect an invalid Date object
TypeScript: An invalid Date has a NaN time value.
TypeScript✓ Tested
Extract reusable toggle behavior
Extract reusable toggle behavior with a small React component and explicit browser behavior.
React✓ Tested
Find values common to two collections
C#: Intersect returns distinct values shared by the inputs.
C#✓ Tested
Find values shared by two collections
Python: Use set intersection and sort the result for deterministic display.
Python✓ Tested
Flatten nested collections
Java: Use flatMap to concatenate nested Java lists into one stream.
Java✓ Tested
Flatten nested collections
Flatten nested collections in a complete Rust program using the standard library.
Rust✓ Tested