Results for “as”
Small, practical examples. Search by task or narrow things down below.
Use a counted Bash loop
Bash Scripts: Use a counted Bash loop with a small standalone Bash program.
Bash Scripts✓ Tested
Use a deque as a FIFO queue
Java: Add at the tail and remove at the head using ArrayDeque.
Java✓ Tested
Use a deque as a stack
Java: Use push and pop for last-in, first-out behavior.
Java✓ Tested
Use a fallback for a missing hashtable entry
PowerShell: Test the key explicitly so legitimate false or zero values are preserved.
PowerShell✓ Tested
Use a function’s exit status as a boolean result
Bash Scripts: Return zero for success and test the function directly in a conditional.
Bash Scripts✓ Tested
Use a hash map for direct key lookup
C++: unordered_map provides key lookup without promising iteration order.
C++✓ Tested
Use a last-in first-out stack
C#: Stack is useful for reversible traversal and other nested operations.
C#✓ Tested
Use a last-in first-out stack
C++: Read top before pop because pop does not return the removed value.
C++✓ Tested
Use a switch expression to classify a value
C#: Relational patterns express a small ordered range classification.
C#✓ Tested
Use an associated constructor
Use an associated constructor in a complete Rust program using the standard library.
Rust✓ Tested
Use case-insensitive dictionary keys
C#: Choose an ordinal comparer when case-insensitive keys represent identifiers.
C#✓ Tested
Validate a simple C-style ASCII identifier
C: Check the first character separately from subsequent characters and reject empty input.
C✓ Tested