FIND YOUR NEXT FEW LINES
Results for “type guard”
Small, practical examples. Search by task or narrow things down below.
225 snippets foundClear filters
Read a property with keyof
Keep the key and returned value tied to an object type.
keyof✓ Tested
Read a small INI configuration
Python: Use ConfigParser typed accessors for configuration values stored as text.
Python✓ Tested
Remove duplicate values with a Set
Keep the first occurrence order while deduplicating.
Set✓ Tested
Represent a record with a dataclass
Python: Generate initialization and convert a typed record to a dictionary.
Python✓ Tested
Return the first item with a generic function
Preserve the element type while allowing empty arrays.
generics✓ Tested
Safely read a caught error
Check the error type before accessing its message.
unknown✓ Tested
Store and retrieve a multibyte integer
Arduino / C: put and get copy the bytes of a typed value.
Arduino / C✓ Tested
Substitute a value for NULL
Use SQL Server’s ISNULL expression.
ISNULL✓ Tested
Update an object with a readonly input
Create a changed copy while retaining the original.
readonly✓ Tested