Results for “collection”
Small, practical examples. Search by task or narrow things down below.
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested
Filter even numbers
Use LINQ Where to keep even C# values.
C#✓ Tested
Filter even numbers
Use a Java stream to collect only even values.
Java✓ Tested
Filter items in a pipeline
Keep numbers that meet a condition.
Where-Object✓ Tested
Join several strings with a separator
PowerShell: The join operator returns one string from an input collection.
PowerShell✓ Tested
Look up a dictionary value
Use TryGetValue for a C# dictionary lookup with a fallback.
C#✓ Tested
Look up a map key
Use find to read a C++ map without inserting a missing key.
C++✓ Tested
Merge two dictionaries
Combine two dictionaries into a new dictionary. When a key appears in both inputs, the value from the second dictionary wins.
dictionary✓ Tested
Pair corresponding values from two arrays
PowerShell: Check lengths before indexing to reject mismatched input collections.
PowerShell✓ Tested
Read a map with a default
Return a fallback when a Java map does not contain a key.
Java✓ Tested
Remove duplicate values
Use LINQ Distinct and OrderBy for a sorted C# result.
C#✓ Tested
Remove duplicate values
Preserve encounter order while removing repeated Java list values.
Java✓ Tested