Results for “or”
Small, practical examples. Search by task or narrow things down below.
Parse a GUID without an exception
C#: TryParse reports malformed values with a boolean return.
C#✓ Tested
Parse a typed command-line option
Python: Use argparse to validate and convert an integer option.
Python✓ Tested
Parse an email address syntax
Parse an email address syntax using a complete Go program with explicit sample inputs.
Go✓ Tested
Parse only valid integers
Parse only valid integers in a complete Rust program using the standard library.
Rust✓ Tested
Partition a collection by a predicate
Java: Use partitioningBy to retain both matching and nonmatching values.
Java✓ Tested
Partition values into two collections
Partition values into two collections in a complete Rust program using the standard library.
Rust✓ Tested
Preconfigure some function arguments
Python: Use partial to produce a callable with selected arguments already bound.
Python✓ Tested
Prevent output chatter with separate thresholds
Arduino / C: Use different on and off thresholds to retain state between them.
Arduino / C✓ Tested
Prevent runtime changes to top-level properties
JavaScript: Object.freeze prevents ordinary top-level mutations; Reflect.set reports the rejected update without throwing.
JavaScript✓ Tested
Prevent runtime changes to top-level properties
TypeScript: Object.freeze prevents ordinary top-level mutations; Reflect.set reports the rejected update without throwing.
TypeScript✓ Tested
Preview removal of an untracked scratch file
Git: The dry-run flag shows what clean would remove without deleting it.
Git✓ Tested
Print a number with two decimal places
Python: Format a small decimal value consistently for display.
Python✓ Tested