FIND YOUR NEXT FEW LINES

Results for “if”

Small, practical examples. Search by task or narrow things down below.

946 snippets foundClear filters
ReactComponents & props

Notify a parent with a callback prop

Notify a parent with a callback prop with a small React component and explicit browser behavior.

React✓ Tested
C++Ownership & optional values

Observe shared ownership without extending its lifetime

C++: A weak_ptr can be locked while an owner exists and becomes expired after the last owner is released.

C++✓ Tested
Arduino / CSerial communication

Print integers in different bases

Inspect a byte in decimal, hexadecimal, and binary.

Serial✓ Tested
C#Collections & data structures

Process a FIFO queue

C#: Queue removes elements in the order they were enqueued.

C#✓ Tested
PythonFunctions & error handling

Raise and catch a domain-specific exception

Python: Give a validation failure its own exception type so callers can handle it narrowly.

Python✓ Tested
GitTags & repository configuration

Read a repository-specific configuration value

Git: The local scope makes configuration lookup predictable for this practice repository.

Git✓ Tested
SQLConstraints & defaults

Reference a parent identified by two columns

SQL: A composite foreign key checks the complete referenced key rather than either column independently.

SQL✓ Tested
SQL ServerConstraints & defaults

Reference a parent identified by two columns

SQL Server: A composite foreign key checks the complete referenced key rather than either column independently.

SQL Server✓ Tested
PostgresConstraints & defaults

Reference a parent identified by two columns

Postgres: A composite foreign key checks the complete referenced key rather than either column independently.

Postgres✓ Tested
SQLiteConstraints & defaults

Reference a parent identified by two columns

SQLite: A composite foreign key checks the complete referenced key rather than either column independently.

SQLite✓ Tested
SQLConstraints & defaults

Reject duplicate business identifiers

SQL: A UNIQUE constraint protects a business key independently of the primary key.

SQL✓ Tested
SQL ServerConstraints & defaults

Reject duplicate business identifiers

SQL Server: A UNIQUE constraint protects a business key independently of the primary key.

SQL Server✓ Tested