Results for “Functions & types”
Small, practical examples. Search by task or narrow things down below.
Create a table and insert its first row
SQL: Define column types and a primary key, then insert one row using an explicit column list.
SQL✓ Tested
Create a table and insert its first row
SQL Server: Define column types and a primary key, then insert one row using an explicit column list.
SQL Server✓ Tested
Create a table and insert its first row
Postgres: Define column types and a primary key, then insert one row using an explicit column list.
Postgres✓ Tested
Create a table and insert its first row
SQLite: Define column types and a primary key, then insert one row using an explicit column list.
SQLite✓ Tested
Define a function with a typed parameter
Accept a name and return a greeting.
function✓ Tested
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested
Give a function an optional argument
Let callers omit a value while keeping nounset enabled.
optional argument✓ Tested
Handle a result with a discriminated union
Separate success data from an error message.
discriminated union✓ Tested
Handle a terminating error
Catch conversion failures and produce a clear fallback.
try catch✓ Tested
Handle an expected command failure
Branch on a command’s exit code without aborting the script.
exit status✓ Tested
Look up values in an associative array
Use named keys for a small in-memory configuration table.
dictionary✓ Tested
Mirror input text
Update a result as the user types using a jQuery input event.
jQuery✓ Tested