Results for “New-Item”
Small, practical examples. Search by task or narrow things down below.
Flatten one level of nested lists
Python: Use a nested comprehension when each input item is itself an iterable.
Python✓ Tested
Format a decimal amount
Use invariant culture to print a C# decimal with two places.
C#✓ Tested
Include untracked files in a stash
Git: The include-untracked option saves new files along with tracked edits.
Git✓ Tested
Initialize a map entry only when absent
Java: Use computeIfAbsent when creating a collection for a new key.
Java✓ Tested
Inspect a revision with detached HEAD
Git: Detached mode is useful for inspection; create a branch before keeping new work.
Git✓ Tested
Join strings with a separator
Combine a list of strings into one readable string with a separator between each item.
string✓ Tested
List matching files
Enumerate immediate text files and sort their names in C#.
C#✓ Tested
Look up a dictionary value
Use TryGetValue for a C# dictionary lookup with a fallback.
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
Move a file into another directory
PowerShell: Move-Item transfers an existing file to the chosen destination directory.
PowerShell✓ Tested
Pass a variable to standard input
Bash Scripts: A here-string supplies the expanded value followed by a newline.
Bash Scripts✓ Tested
Preserve line breaks while collapsing repeated spaces
CSS: Pre-line retains newlines but does not preserve all whitespace like pre-wrap does.
CSS✓ Tested