Results for “when”
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
Generate a sequence of numbers
Create rows without a stored table.
generate_series✓ Tested
Generate a stepped sequence
Linux Commands: Use seq when a command pipeline needs a numeric sequence.
Linux Commands✓ Tested
Give a section an accessible region name
HTML: A section becomes a named landmark when its heading is referenced with aria-labelledby.
HTML✓ Tested
Give implicit grid rows a minimum height
CSS: Minmax allows an implicit row to grow when its content requires more room.
CSS✓ Tested
Group strings by their length
Java: Choose a TreeMap supplier when group keys must have deterministic order.
Java✓ Tested
Handle a failed string-to-integer conversion
C++: stoi throws invalid_argument when no conversion can be performed.
C++✓ Tested
Handle a nonzero background-job exit
Bash Scripts: Wait reports a child’s exit code; put it in a conditional when failure is expected.
Bash Scripts✓ Tested
Handle an expected child-process failure
Python: Catch CalledProcessError when check=True reports a nonzero exit status.
Python✓ Tested
Highlight a group containing keyboard focus
CSS: Focus-within matches a parent when any descendant has focus.
CSS✓ Tested
Include missing values in a not-equal filter
SQL: Ordinary inequality does not include NULL; explicitly include it when that is the intended rule.
SQL✓ Tested
Include missing values in a not-equal filter
SQL Server: Ordinary inequality does not include NULL; explicitly include it when that is the intended rule.
SQL Server✓ Tested