Zig w/ Example

Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

Zig w/ Example is a collection of code examples written in Zig to show the solutions to various common programming problems.

Most of these examples assume that you have some prior knowledge about the language. If you're new to the language, it's highly recommended that you read the official documentations first.

  1. Environment Variables

    1. List all environment variables
  2. File

    1. Create/write file
    2. Append data to file
    3. Check if a file exists
    4. Read file
    5. Read file in small chunks
    6. Read/write file
    7. Delete file
  3. Function

    1. Anonymous function
    2. Nested function
    3. Variadic function
  4. JSON

    1. Encode into JSON
    2. Decode from JSON
    3. Decode: Handling null
    4. Decode: Handling duplicate/unknown key
    5. Decode JSON dynamically
    6. Validate JSON
  5. Random Number Generator

    1. Int/float/bool
    2. Seed
    3. Random bytes
    4. Shuffle an array/slice
  6. String Handling

    1. Copy
    2. Equal
    3. Contains