Results for “Object behavior & collections”
Small, practical examples. Search by task or narrow things down below.
Check for a hashtable key before reading it
PowerShell: ContainsKey distinguishes a missing key from a key whose value happens to be null.
PowerShell✓ Tested
Choose a local file through a labeled control
HTML: A file input exposes selected file metadata to the page without providing arbitrary filesystem access.
HTML✓ Tested
Collect several checked values under one name
HTML: Only checked named checkboxes become successful form controls.
HTML✓ Tested
Construct a record with named properties
PowerShell: PSCustomObject gives downstream pipeline commands meaningful property names.
PowerShell✓ Tested
Copy a slice without sharing storage
Copy a slice without sharing storage using a complete Go program with explicit sample inputs.
Go✓ Tested
Deduplicate sorted values
Deduplicate sorted values using a complete Go program with explicit sample inputs.
Go✓ Tested
Disable a related group of controls
HTML: A disabled fieldset prevents editing its descendant controls and omits them from form submission.
HTML✓ Tested
Enumerate hashtable entries in a stable order
PowerShell: Sort entries by key when predictable output matters.
PowerShell✓ Tested
Filter values into a new slice
Filter values into a new slice using a complete Go program with explicit sample inputs.
Go✓ Tested
Find an item’s index
Find an item’s index using a complete Go program with explicit sample inputs.
Go✓ Tested
Find values missing from another collection
C#: Except removes duplicates as it calculates the set difference.
C#✓ Tested
Fit an entire image inside a differently shaped box
CSS: Contain preserves the image aspect ratio while keeping all of it visible inside the specified content box.
CSS✓ Tested