Results for “new”
Small, practical examples. Search by task or narrow things down below.
Correct the latest unpublished commit message
Git: Amend replaces the current commit while preserving its tree when no new changes are staged.
Git✓ Tested
Count lines in a file
Count newline characters in a text file, printing only the count without the filename.
lines✓ Tested
Count words with GroupBy
Group repeated C# words and print ordered counts.
C#✓ Tested
Create a file only when it does not exist
C#: FileMode.CreateNew prevents accidental replacement of existing content.
C#✓ Tested
Create and switch to a branch
Start an isolated feature branch from the current commit.
switch✓ Tested
Create nested directories
Create a directory tree using the .NET Directory API.
C#✓ Tested
Filter a list with a condition
Build a new list containing only the values that satisfy a condition using a list comprehension.
list✓ Tested
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
Find text ignoring case
Use ordinal case-insensitive comparison for a C# substring search.
C#✓ Tested
Flatten a single nesting level
JavaScript: flat defaults to a depth of one and creates a new array.
JavaScript✓ Tested
Flatten a single nesting level
TypeScript: flat defaults to a depth of one and creates a new array.
TypeScript✓ Tested