Results for “optional chaining”
Small, practical examples. Search by task or narrow things down below.
Provide a default for a missing value
Provide a default for a missing value in a complete Rust program using the standard library.
Rust✓ Tested
Read a variant only when it holds the expected type
C++: get_if returns a null pointer rather than throwing for another active alternative.
C++✓ Tested
Run cleanup through a scoped destructor
C++: A stack object’s destructor runs when its scope exits, including normal exception unwinding.
C++✓ Tested
Share ownership with a counted smart pointer
C++: Copies of shared_ptr keep the owned value alive until the last owner is released.
C++✓ Tested
Stop collecting when parsing fails
Stop collecting when parsing fails in a complete Rust program using the standard library.
Rust✓ Tested
Store a reference in a standard container
C++: reference_wrapper preserves reference semantics while behaving like a copyable container element.
C++✓ Tested
Transfer unique ownership with move
C++: Moving a unique_ptr leaves the source empty and gives ownership to the destination.
C++✓ Tested
Avoid a shared mutable default argument
Python: Create a fresh list inside the function when the optional argument is omitted.
Python✓ Tested
Create a native disclosure
Use details and summary to show optional HTML content without JavaScript.
HTML✓ Tested
Drop capabilities for a Compose service
Docker / Compose: cap_drop ALL removes optional Linux capabilities.
Docker / Compose✓ Tested
Find the final day of a month
Use EOMONTH without manually calculating month length.
EOMONTH✓ Tested
Test missing values with IS NULL
Find rows where an optional value is absent.
IS NULL✓ Tested